How to take Postgres data snapshot

While we are working on Postgres replication or doing backup, we do face many issue like we can’t take database backup one by one, at that time we can use the ” data snapshot” utility to take the backup for whole “data” directory of Postgres and restore it on another server or on same server, when we want. To take the ” data snapshot” , make sure that you have been logged in as a root user and after that switch to the respective postgres admin user to take the ” data snapshot”.

Refer to the following login details to take the ” data snapshot”.

1st) Login into the Server as root user and switch to the Postgres admin user, for example

ssh to the server

root@ServerIP  or root@hostname

su – postgres

Now run the command to take the /data folder backup

psql -c "SELECT pg_start_backup('replbackup');"

Now compress the backup or “data snapshot”

tar cfP /tmp/db_file_backup.tar /opt/PostgresPlus/9.0AS/data

Once backup or “data snapshot” completed the close the backup process.

./psql -c “SELECT pg_stop_backup();”

About Anant 373 Articles
Senior technical writer