chiark / gitweb /
Add a daily backup cron job to the Debian package.
[disorder] / debian / disorder.daily
1 #! /bin/sh
2 set -e
3
4 # Maximum backup age
5 MAXAGE=7
6
7 # Enable backups
8 BACKUP=true
9
10 # Enable pruning
11 PRUNE=true
12
13 # All operator to override settings
14 if test -e /etc/default/disorder; then
15   . /etc/default/disorder
16 fi
17
18 if ${BACKUP}; then
19   # Ensure the backup directory exists
20   mkdir -m 0700 -p /var/lib/disorder/backups
21
22   # Take a backup
23   disorder-dump --dump /var/lib/disorder/backups/$(date +%F)
24 fi
25
26 if ${PRUNE}; then
27   # Delete old backups
28   find /var/lib/disorder/backups -type -f -ctime +${MAXAGE} -print0 \
29   | xargs -r0 rm -f
30 fi