wal compressed archive and restore
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 11 Sep 2021 12:44:45 +0000 (14:44 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 11 Sep 2021 12:44:45 +0000 (14:44 +0200)
db.txt

diff --git a/db.txt b/db.txt
index 2f65fd6..ad4764e 100644 (file)
--- a/db.txt
+++ b/db.txt
@@ -123,13 +123,12 @@ dpavlin=# insert into test(t) select i from generate_series(100, 150) as i ;
 
 
 dpavlin=# SELECT pg_start_backup('label', false, false);
-
+- fs backup
 SELECT * FROM pg_stop_backup(false, true);
 
 
 
 
-[root@slave 10]# mkdir /var/lib/pgsql/10/archive.base/
 
 # tuning
 
@@ -151,3 +150,62 @@ To activate it immediately, run:
 
 mount -o remount,noatime,nodiratime /pgdata
 
+
+# compressed archive_command
+
+https://www.postgresql.org/docs/10/continuous-archiving.html
+
+archive_command = 'gzip < %p > /var/lib/pgsql/archive/%f'.
+
+systemctl reload postgresql-10
+
+/usr/pgsql-10/share/recovery.conf.sample
+
+restore_command = 'gunzip < /var/lib/pgsql/10/archive/%f > %p'
+
+!!! full_page_writes on master for pg_basebackup on slave
+!!! logging_collector on if archive_command script used
+
+## create full backup
+
+[root@slave 10]# pg_basebackup --host localhost --username postgres --progress --format t --gzip --write-recovery-conf --pgdata /tmp/test-2021-09-11/ --label test-2021-09-11
+119004/119067 kB (99%), 1/1 tablespace
+
+
+
+## restore backup
+
+mkdir /tmp/r
+chown postgres:postgres /tmp/r
+chmod 700 /tmp/r
+
+tar xvf /tmp/test-2021-09-11/base.tar.gz -C /tmp/r/
+tar xvf /tmp/test-2021-09-11/pg_wal.tar.gz -C /tmp/r/pg_wal/
+
+cp /var/lib/pgsql/10/recovery.conf /tmp/r/
+vi /tmp/r/recovery.conf
+
+cat postgresql.conf | grep -v archive_mode | grep -v archive_command > postgresql.conf.new && mv postgresql.conf.new postgresql.conf
+
+su postgres -c '/usr/pgsql-10/bin/pg_ctl -D /tmp/r start -o "-p 5433"'
+
+su postgres -c '/usr/pgsql-10/bin/pg_ctl -D /tmp/r stop'
+
+
+
+# TODO
+
+- diskovi
+- archive_command na dr
+
+
+- cdu backup strategy (archive na nfs?)
+- sysctl.conf na svim db-ovima
+- fs noatime,nodiratime na svim db-ovima
+- monitoring db-ova
+- reboot db-ova
+- pristup na grafanu
+- shared screen na serveru (ssh -R ?)
+- test pitr recovery 
+- failover (promjena ip-ja u aplikaciji?)
+