Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you actually restore a backup? #3873

Open
sepastian opened this issue Nov 28, 2024 · 6 comments
Open

How do you actually restore a backup? #3873

sepastian opened this issue Nov 28, 2024 · 6 comments

Comments

@sepastian
Copy link

First, thanks for Grav, not having to use a db for simple applications is great.

I am hosting a Grav site, which I did not build myself, using a Docker container. I have received the site as a zipped backup.

The documentation talks about how to create and manage backups.

But there's no information about a restoring mechanism. Without being able to restore a backup, there's not point in creating backups in the first place.

How do you restore a backup created by Grav, according to the documentation, into a newly created instance? Even better, if the instance is running inside a Docker container?

Am I missing something obvious here? Could you please point me at where to look?

@rhukster
Copy link
Member

There no restore because Grav is file based so just extract the zip using standard tools (which depend on your hosting situation). There’s no special steps required. The backup is like a snapshot of your site, so just need to put the files in the right folder, over-writing existing files if needed.

@sepastian
Copy link
Author

sepastian commented Nov 28, 2024

Thanks for the quick reply @rhukster!

Let me try that in Docker, see below...

# start the grav container
$ docker run --rm -p 8080:80 --name grav lscr.io/linuxserver/grav:latest
:
[ls.io-init] done.

Go to http://localhost:8080 and setup a new site.

(Minor issue: after setup, Grav will redirect me to http://localhost/admin, but the container port 80 is connected to 8080 at the host. There's probably a setting in Grav to fix that...)

Now extract the backup.

Note: I first tried to extract the backup into /app/www/public, then replace the symlink /app/www/public/user with the user/ folder from the backup. That did not work. What works: replace /config/www/user inside the container with user/ from the zipped backup. See below.

# replace /config/www/user inside container
# with user/ folder from zipped backup
$ docker cp backup.zip grav:/tmp
$ docker exec grav /bin/bash \
  -c 'unzip /tmp/backup.zip \
    && rm -rf /config/www/user \
    && cp -r /tmp/backup/user /config/www \
    && chown -R abc:abc /config/www/user'

The site works, but I would like to start Grav with docker compose, instead of manually copying the backup into the running container. Probably by either mounting the user/ directory from the zipped backup to the right place. Or by extracting the backup automatically during startup, much like the Mongo does with files placed in /docker-entrypoint-initdb.d during initialization.

Is that possible (already) with Grav Docker? I.e. can a backup be restored before running setup on a new instance of Grav?

@sepastian
Copy link
Author

So, my question is, aside from Docker:

I replaced /config/www/user with the user/ folder from the zipped backup. I skipped the logs/ and backups/ folders.

Anything else I need to do to restore a backup?

@domhaas
Copy link

domhaas commented Nov 29, 2024

So, my question is, aside from Docker:

I replaced /config/www/user with the user/ folder from the zipped backup. I skipped the logs/ and backups/ folders.

Anything else I need to do to restore a backup?

There should be no logs or backups folder inside the user-folder - those should be at /
Maybe your backup was from an older grav-installation?

@sepastian
Copy link
Author

Does the backup itself contain the version of Grav used to create the backup?

@rhukster
Copy link
Member

rhukster commented Dec 1, 2024

it just zip's up the site's current directory,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants