瀏覽代碼

Stops postgresql for tarsnap backup

Data loss will occur if backing up postgresql while it runs. A simple
fix is to stop it during the backup. I've moved the backup to early
morning to reduce possible downtime.

A better approach would be to use pg_dump.
James Ravn 11 年之前
父節點
當前提交
146c587644
共有 2 個檔案被更改,包括 7 行新增1 行删除
  1. 6
    0
      roles/tarsnap/files/tarsnap.sh
  2. 1
    1
      roles/tarsnap/tasks/tarsnap.yml

+ 6
- 0
roles/tarsnap/files/tarsnap.sh 查看文件

@@ -54,12 +54,18 @@ else
54 54
 	BACKUP="$YEAR$MOY$DOM-$TIME-daily"
55 55
 fi
56 56
 
57
+# Stop postgres
58
+service postgresql stop
59
+
57 60
 # Do backups
58 61
 for dir in $DIRS; do
59 62
 	echo "==> create $BACKUP-$dir"
60 63
 	$TARSNAP $EXTRA_FLAGS -c -f $BACKUP-$dir $dir
61 64
 done
62 65
 
66
+# Start postgres
67
+service postgresql start
68
+
63 69
 # Backups done, time for cleaning up old archives
64 70
 
65 71
 # using tail to find archives to delete, but its

+ 1
- 1
roles/tarsnap/tasks/tarsnap.yml 查看文件

@@ -61,4 +61,4 @@
61 61
   copy: src=tarsnap.sh dest=/root/tarsnap.sh mode="755"
62 62
 
63 63
 - name: Install nightly Tarsnap-generations cronjob
64
-  cron: name="Tarsnap backup" hour="23" minute="0" job="sh /root/tarsnap.sh >> /var/log/tarsnap.log"
64
+  cron: name="Tarsnap backup" hour="3" minute="0" job="sh /root/tarsnap.sh >> /var/log/tarsnap.log"

Loading…
取消
儲存