From d376fcfa326c40b4a130004e7f745994fe609706 Mon Sep 17 00:00:00 2001 From: wbudic Date: Wed, 18 Aug 2021 17:59:02 +1000 Subject: [PATCH] Added how to backup/restore. --- Installation_PostgreSQL.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Installation_PostgreSQL.txt b/Installation_PostgreSQL.txt index 6b68a7c..a5d574f 100644 --- a/Installation_PostgreSQL.txt +++ b/Installation_PostgreSQL.txt @@ -75,6 +75,20 @@ sudo -u postgres psql -c "SHOW data_directory;" | grep -G / ## Quick tar all sudo tar czvf ~/postgresql.db.backup.tar $(sudo -u postgres psql -c "SHOW data_directory;" | grep -G /) +# Backup/Restore +# You must setup an ~/.pgpass, and change the following cat string to your systems setup. + +cat "hostname:port:database:username:password" >> ~/.pgpass; chmod 600 ~/.pgpass; + +# Backup with: +pg_dump --file "~/dev/LifeLog/dbLifeLog/bck-pg-$DB_NAME.sql" $DB_NAME + +# Now you can run your backup utility. To include your ~/dev/ directory. +# Or use and setup mine @see -> https://github.com/wbudic/B_L_R_via_sshfs +# p.s. If this saved you one day, let me know. :) + +# Restore with: +psql $DB_NAME < "~/dev/LifeLog/dbLifeLog/bck-pg-$DB_NAME.sql" -- 2.34.1