From 4067c73b996290c69bc3ed1cd35588a18298d85b Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 21 Mar 2016 14:40:56 +0100 Subject: [PATCH] library/roles/mysql/templates/mysql-backup.cron.j2, library/roles/postgresql/files/postgresql-backup.cron: do not perform backups if backuppc is running successfully. --- mysql/templates/mysql-backup.cron.j2 | 11 +++++++++++ postgresql/files/postgresql-backup.cron | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/mysql/templates/mysql-backup.cron.j2 b/mysql/templates/mysql-backup.cron.j2 index d32cb67..02134e2 100755 --- a/mysql/templates/mysql-backup.cron.j2 +++ b/mysql/templates/mysql-backup.cron.j2 @@ -6,6 +6,17 @@ if [ -x /etc/cron.daily/duplicity_backup ] ; then exit 0 fi +# Remote backup performed by BackupPC. If it is active, do not run via cron +if [ -f /var/log/backuppc.log ] ; then + TMSTMP=$( date +%s ) + . /var/log/backuppc.log + LAST_BACKUP_TIME=$( expr $TMSTMP - $BACKUP_TIMESTAMP ) + if [ $LAST_BACKUP_TIME -gt 86400 -a $BACKUP_RESULT == 'OK' ] ; then + echo "BackupPC is active, doing nothing" > $LOG_FILE + exit 0 + fi +fi + /usr/local/sbin/mysql-backup > $LOG_FILE 2>&1 exit 0 diff --git a/postgresql/files/postgresql-backup.cron b/postgresql/files/postgresql-backup.cron index d8374cf..c4a792c 100755 --- a/postgresql/files/postgresql-backup.cron +++ b/postgresql/files/postgresql-backup.cron @@ -11,6 +11,23 @@ else PG_BCK_BIN=/usr/local/sbin/postgresql-backup fi +# Remote backup performed by duplicity. When active, do not run via cron +if [ -x /etc/cron.daily/duplicity_backup ] ; then + echo "duplicity backups active. Exiting" > $LOG_FILE + exit 0 +fi + +# Remote backup performed by BackupPC. If it is active, do not run via cron +if [ -f /var/log/backuppc.log ] ; then + TMSTMP=$( date +%s ) + . /var/log/backuppc.log + LAST_BACKUP_TIME=$( expr $TMSTMP - $BACKUP_TIMESTAMP ) + if [ $LAST_BACKUP_TIME -gt 86400 -a $BACKUP_RESULT == 'OK' ] ; then + echo "BackupPC is active, doing nothing" > $LOG_FILE + exit 0 + fi +fi + export PATH="/sbin:/usr/sbin:/usr/local/sbin:$PATH" PG_SVC=$( service $PG_SERVICE status >/dev/null ) PG_RUNNING=$?