From c214e2941f4766d9706b4447989576b311122024 Mon Sep 17 00:00:00 2001 From: mark-cohen Date: Mon, 8 Aug 2016 20:41:15 -0700 Subject: [PATCH 1/2] Added backup retention components --- backup.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backup.sh b/backup.sh index 0b08906..2942415 100644 --- a/backup.sh +++ b/backup.sh @@ -21,6 +21,8 @@ EXCLUDE="/Library/Scripts/Backup/rsync_excludes.txt" # set email notification address EMAIL="admin@org.ca" +# KEEP_BACKUPS=7 + if [ ! -d "$LOG_DIR" ]; then mkdir $LOG_DIR fi @@ -44,4 +46,12 @@ echo Backup complete >> /Library/Logs/backup.log date >> /Library/Logs/backup.log # cat /Library/Logs/backup.log | mail -s "Client: Server - backup complete" $EMAIL +backups_count=ls -1 $BACKUP_DIR | wc -l +backups_to_remove=$(($backups_count-$KEEP_BACKUPS)) +if [ $backups_to_remove -gt 0 ]; then +for d in ls -1 $BACKUP_DIR | head -n$backups_to_remove; do +docmd "rm -rf $BACKUP_DIR/$d" +done +fi + exit From 2c072ff784ad4663e491f5607bfff80946f5e230 Mon Sep 17 00:00:00 2001 From: mark-cohen Date: Mon, 8 Aug 2016 20:44:32 -0700 Subject: [PATCH 2/2] Changed retention to 14 days from 7 --- backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index 2942415..11b61cb 100644 --- a/backup.sh +++ b/backup.sh @@ -21,7 +21,7 @@ EXCLUDE="/Library/Scripts/Backup/rsync_excludes.txt" # set email notification address EMAIL="admin@org.ca" -# KEEP_BACKUPS=7 +# KEEP_BACKUPS=14 if [ ! -d "$LOG_DIR" ]; then mkdir $LOG_DIR