Create a backup of a production PostgreSQL database:
- SSH into your server (e.g. by using PuTTY).
- Use
pg_dumpwith the correct user and database. Example: pg_dump --username "myadminuser" --format custom --blobs --verbose --file "mybackupfile.sql" "mydatabase"- Submit the correct password when prompted.
- The file is created in the directory you executed
pg_dumpfrom unless you specified a path. - You can pick this file up via an FTP client or by using pscp from a command prompt.
Restore the backup to a local development database:
- Use
psqlwith the correct user, file and database. Example: psql --username "mylocaladmin" "mydatabase" << "mybackupfile.sql"