Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automate the backup of your projects locally and remove old backups.
#!/bin/bash
# Automate the backup of your projects locally and remove old backups.
# Run a daily cronjob such as:
# 0 1 * * * bash /etc/cron.daily/code_backup.sh >/dev/null 2>&1
# Author: Zaid Daba'een
projects=( project1 project2 project3 )
for i in "${projects[@]}"
do
tar -zcf /var/backup/$i-`date +\%Y\%m\%d`.tar.gz /var/www/sites/$i
done
find /var/backup/ -type f -mtime +2 -exec rm -f {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment