From 44dae7353c3fdc631e315176be50448fb829a9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Fri, 30 Nov 2018 17:46:59 +0200 Subject: [PATCH] Gzip wal_archives --- optional/postgresql/conf/postgresql.conf | 2 +- optional/postgresql/postgres_crontab | 2 +- optional/postgresql/start.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/optional/postgresql/conf/postgresql.conf b/optional/postgresql/conf/postgresql.conf index 92f81307..97c5391f 100644 --- a/optional/postgresql/conf/postgresql.conf +++ b/optional/postgresql/conf/postgresql.conf @@ -216,7 +216,7 @@ checkpoint_warning = 15s # 0 disables archive_mode = on # enables archiving; off, on, or always # (change requires restart) -archive_command = 'test ! -f /backup/wal_archive/%f && cp %p /backup/wal_archive/%f' # command to use to archive a logfile segment +archive_command = 'test ! -f /backup/wal_archive/%f && gzip < %p > /backup/wal_archive/%f' # command to use to archive a logfile segment # placeholders: %p = path of file to archive # %f = file name only # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' diff --git a/optional/postgresql/postgres_crontab b/optional/postgresql/postgres_crontab index 2d45c5a2..ce87e1e2 100644 --- a/optional/postgresql/postgres_crontab +++ b/optional/postgresql/postgres_crontab @@ -1 +1 @@ -11 4 * * * /basebackup.sh > /proc/1/fd/1 2>/proc/1/fd/2 +11 4 * * 7 /basebackup.sh > /proc/1/fd/1 2>/proc/1/fd/2 diff --git a/optional/postgresql/start.py b/optional/postgresql/start.py index ea278d56..5d5b2bc6 100755 --- a/optional/postgresql/start.py +++ b/optional/postgresql/start.py @@ -38,7 +38,7 @@ if not os.listdir("/data"): subprocess.call(["tar", "--same-owner", "-zpxf", base_backups[-1] + "/base.tar.gz" , "-C", "/data"]) if os.listdir("/backup/wal_archive"): with open("/data/recovery.conf", "w") as rec: - rec.write("restore_command = 'cp /backup/wal_archive/%f %p'\n") + rec.write("restore_command = 'gunzip < /backup/wal_archive/%f > %p'\n") rec.write("standby_mode = off\n") os.system("chown postgres:postgres /data/recovery.conf") #os.system("sudo -u postgres pg_ctl start -D /data -o '-h \"''\" '")