Automatic backup
This bash script will backup all files changed in the past 60 minutes.
So I run it thru cron 0 * * * * sh bkp.sh
Este script bash salva os arquivos alterados nos últimos 60 minutos. Executado via cron.
#!/bin/bash
# Local directory for dump files
LOCALDIR=/etc/backup/sites
FPATH=/var/www/site
#####################################
### Edit Below If Necessary #########
#####################################
cd $LOCALDIR
DATE=`eval date +%Y%m%d-%H%M`
# compact
tar cjf och_${DATE}.tar.bz2 `find ${FPATH} -type f -mmin -60|sort`
# protect
chmod 0440 *bz2
# Delete files older than 14 days
for i in `find $LOCALDIR -mtime +14|sort`; do (rm $i); done;