Posts

How to restore an encrypted dokku postgres dump to your local dev environment

Dienstag, 07. März 2023, 16:23 Uhr | roberto@vasquez-angel.de |

Go to the s3 storage, locate the dump and download it. Let’s assume the file is called dump.tgz.gpg

Decrypt the dump using the passphrase/key you have safely stored (i.e. in a password manager):

#> gpg --pinentry-mode=loopback --passphrase "<passphrase>" -d -o dump.tgz dump.tgz.gpg

Create a directory as unpacking target:

#> mkdir dump

Unpack the dump:

#> tar zxvf dump.tgz -C dump

Drop the current database and recreate it, so it is empty. If you are using rails you can use following commands:

#> rails db:drop && rails db:create

Restore the dump to your local postgres database:

#> pg_restore -U <username> -d <database_name> --no-owner < dump/backup/export