Anybody wrote a Weekly Auto Restore Script

I am trying to write a script with a cron that can automatically restore my backup from s3 weekly.

So it can run every sunday instead of me going in UI and restore it. (Our site’s restore takes a couple hour…)

Did anybody do anything similar?

Why do you need to restore so frequently?

Is your site corrupting on a weekly basis?

1 Like

This is for a test-site. So i can try experimenting settings/things.

1 Like

To check if the backups are actually ok? Did you know most people do not actually perform restore tests.

If I would do this, I would spin up a isolated docker container to restore the backup. This docker container would be destroyed after a successful restore. This new container would not be allowed to communicate to the outside world (e.g. not send any emails, not download new content, etc.).

Restoring a backup could be a simple docker exec with the commands

discourse enable_restore
discourse restore <backup>.tar.gz

But you need the same container image for the site to verify… So maybe a image rebuild after the restore? and then verify.

1 Like
docker exec app bash -c '$(discourse restore | grep discourse|head -1)'

will restore the latest backup. Then you’d just get chron to run it when you want.

3 Likes