NOTE: THIS HAS NOT BEEN FULLY TESTED!
Create a cron.daily job to backup a directory
Below is the script for backing up website directory.
mkdir -p /data/backups/www
File location: /etc/cron.daily/www_backup
#!/bin/sh # # WWW backup script # NOW=$(date +"%Y-%m-%d-%H-%M-%S") # BACKUPLOC="/data/backups" WWWBACKUPLOC="$BACKUPLOC/www" BACKUPFILE="$WWWBACKUPLOC/backup-www-${NOW}.tar.gz" LOGFILE="$WWWBACKUPLOC/backup-www-${NOW}.log" FILE_DIR_PATH="/data/www" # # Backup Data tar -zcvf ${BACKUPFILE} -C $FILE_DIR_PATH . > $LOGFILE chmod 600 $BACKUPFILE # /usr/bin/find $WWWBACKUPLOC/backup-www*.tar.gz -mtime +7 -exec rm {} \; /usr/bin/find $WWWBACKUPLOC/backup-www*.log -mtime +7 -exec rm {} \; # exit 0
chmod 700 /etc/cron.daily/www_backup