How to restore a production backup on a staging site

Restoring backups of production servers on a staging server can be tricky. This is the least error-prone way of approaching it.

  1. Download a backup of the production site without uploads (this is an option when you create a backup from the admin backups UI). Uploads pose a number of potential issues when restoring a backup on a site other than the one where the backup was generated.

  2. Restore the backup on the staging server following the instructions here: https://meta.discourse.org/t/restore-a-backup-from-command-line/108034. There are fewer sources of error when you restore from the command line, and you don’t need to deal with getting logged out while the backup is going on.

  3. When the restore is complete, the first thing you should do is ensure the site setting disable_emails is set to ‘yes’. You can do this from the command line as follows:

    ./launcher enter app
    rails c
    SiteSetting.disable_emails = 'yes'
    

cc @Eli

Heh. I think you mean "this is least error-prone way of approaching it.

Good advice, nonetheless - thanks for sharing. I’ve recently started playing with multisite to try to split up three communities that had been cohabitating the same site, and restoring the backup from the command line was a great way to do it. I also disabled emails right away to avoid spamming folks from the other sites while I am deleting users and content that is not relevant for their sites.