Backup and Restore PostgreSQL Databases
Table of Contents
- Backup a PostgreSQL database
- Restore the PostgreSQL database
- Recovery test a PostgreSQL recovery point
Elastio supports PostgreSQL database backup and restore in the Elastio CLI. PostgreSQL restore is not available on Windows for the time being, but Windows support is planned for the upcoming versions.
Backup a PostgreSQL database
Run this command to create a full database backup that we will restore in further examples.
Note: If the password contains special symbols it should be wrapped in ‘ like so: ‘password’.
elastio postgres backup --database <database-name> --user <user-name> --password <password>
An example output can be viewed below:
Ingested 198.86MB in 2 item(s) in 1 minute (2.18MB/s, 130.62MB/m)
New: 198.86MB (2.18MB/s, 130.62MB/m)
Existing: 0B (0B/s, 0B/m)
Skipped: 0B (0B/s, 0B/m)
Recovery point ID: rp-01gjmnz4748qbqnh7wqmbwzfyr
Restore the PostgreSQL database
Use the recovery point ID for the database you are willing to restore:
elastio postgres restore --rp <elastio-rp-id> --user <user-name> --password <password>
Recovery test a PostgreSQL recovery point
You can run a recovery test on a recovery point to make sure the structure of the RP is intact and preserved identical to the original.
To run the test use the following command:
elastio postgres recovery-test --postgres-script-s3-url s3://postgres-test-5590/database-validator-gt-1000.txt --rp <elastio-rp-id> --monitor
The --postgres-script-s3-url
file is the test file stored on an S3. The correct URL should be provided to run the test. The test will vary for different DBs. See a very basic test example below:
{
tests: [
{
database: 'test_01',
conditions: [
{
Query: {
query: 'SELECT * FROM companies;',
predicates: [
{
rows: {
greater_than: '1000',
},
},
],
},
},
],
},
],
}