Skip to content

Instantly share code, notes, and snippets.

@gidj
Last active September 6, 2017 19:41
Show Gist options
  • Save gidj/b886df2508024eb9d95509c765b09400 to your computer and use it in GitHub Desktop.
Save gidj/b886df2508024eb9d95509c765b09400 to your computer and use it in GitHub Desktop.
Restoring a gzipped SQL dump
# First get the file:
scp ubuntu@10.0.1.120:~/rds_backups/backup-2017-08-27.sql.gz ./
# Drop and create the template database:
sudo -u postgres dropdb aya_prod && sudo -u postgres createdb aya_prod
# Copy it to the virtual disk, then create a new database with it:
gunzip < database.sql.gz | sudo -u aya psql aya_prod
# As long as that goes well, drop and create the production database using the template database
sudo -u postgres dropdb aya
sudo -u postgres psql
> CREATE DATABASE aya WITH TEMPLATE aya_prod OWNER aya ENCODING='UTF8';
# And you're finished!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment