PoC
Setup
- create an Ubuntu VM
- install postgres
Backup
- Assumes you have a shell access running postgres instance.
- If you're trying to do this over a network, you'll need to figure out other options for the commands run (e.g. host, port, etc.)
Steps
1. Go to a directory where the postgres
user has write access
2. Create a Backup file
!!! Note If you're not certain on which tool to use, try to use the pg_dumpall
.
2.A. Using pg_dump
Only dumps a single database named postgres
.
- Option 1: Write to SQL file
- Option 2: Write to .dump file
2.B. Using pg_dumpall
- Option 1: Write to SQL file
- Option 2: Write to .dump file
Upload the backup file to a remote storage
- Create a script that will upload the backup file to a remote storage (e.g. AWS S3, Azure Blob Storage, etc.)
Restore
Restore a Single DB
We are now working on the host machine that'll be backed up to.
[IA] Delete the existing DB from the server
[IA] Create a new DB to restore to
Create a new DB named new-db-name
from the template0
template.
Restore a single DB from .sql file
SQL files are restored with psql
.
Restore a Entire DB Server
Check the Restoration
Enter the psql shell to verify the restore was successful.
Run psql commands: