Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ EXCLUDE="/Library/Scripts/Backup/rsync_excludes.txt"
# set email notification address
EMAIL="admin@org.ca"

# KEEP_BACKUPS=14
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value should be customized based on org's retention policy.


if [ ! -d "$LOG_DIR" ]; then
mkdir $LOG_DIR
fi
Expand All @@ -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