-
-
Save dtuite/7473583 to your computer and use it in GitHub Desktop.
Backup and Restore a PostgreSQL Database
First, ssh into your server and run the following command to create a dump file.
pg_dump -U [DB_USER_NAME] [DB_NAME] -f [DUMP_FILE_NAME].sql
Next, copy the file to your local machine:
scp [SERVER_DEPLOYMENT_USER]@[SERVER_IP]:~/[PATH_TO_DUMP_FILE] ./
Restore:
psql -U [DB_USER_NAME] -d [DESTINATION_DB_NAME]-f [DUMP_FILE_NAME].sql
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment