Restoring a Backup

A backup service is only as good as its ability to restore a backup when needed, and Remora Backup is no exception.

We’ve made the process of downloading and decrypting your most recent backup as simple as possible. Below we’ll outline the steps that are needed in a simple scenario.

Here’s a common scenario: you need a snapshot of your production data for use on your local machine. It may be for investigation purposes, it may be to test a new piece of code, etc. Regardless, you want to load a recent backup of production into your local Postgres server. With Remora Backup, this process is easy.

We’re going to walk through the steps to download, decrypt, and load your backup via the command line.

Download the Latest Backup File

You will first need to get the host, login, and password for your Remora Backup location. This is where your encrypted backups are stored offsite. These values can be found in the Remora Backup Dashboard, accessible via the Resources section of your Helper App in the main Heroku Dashboard interface. Once you have these values, you can use scp to download the latest backup, as detailed below:

$ scp LOGIN@backup.remorabackup.com:db_backup.gpg .

You will be prompted for your password, which you can copy then paste from your Dashboard.

Once you’ve entered your password correctly, the backup file will download to your local machine. Depending on the size of your backup, it may take some time.

Decrypt Your Backup

Once the file has downloaded, you will need to decrypt it, using the gpg utility. If you don’t have gpg installed, you can get it here. If you’re running macOS, we recommend installing gpg via the Homebrew formula.

Be sure to copy your decryption key, then run this command:

$ gpg --decrypt --output db_backup db_backup.gpg

You will be prompted for your decryption key, and then the decryption process will run. For a large file, it will take some time. Once complete, you should have two files: the original encrypted backup, and the newly decrypted backup:

$ ls -lh
total 1680
-rw-r--r-- 1 demo staff 417K Jan 25 10:19 db_backup
-rw------- 1 demo staff 417K Jan 25 10:11 db_backup.gpg

Restoring Your Backup to Postgres

Be sure you have a local Postgres database created and ready to restore to. In this example, we’ve already created the restored_db database in our local Postgres server.

pg_restore -v -c -d restored_db -h *your_host* -U *your_user* db_backup

There are other options for the pg_restore command that you may consider using. View the full documentation for more details.