Automate the backup of your projects locally and remove old backups.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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