De un archivo de configuración (/etc/backup/domains):
#!/bin/bash
echo `date`
if [ -s /etc/backup/domains ] ; then
while read line; do
backupwww.sh $line
done < /etc/backup/domains
fi
echo `date`
echo `date`
if [ -s /etc/backup/domains ] ; then
while read line; do
backupwww.sh $line
done < /etc/backup/domains
fi
echo `date`
Leer los dominios en /www y llamar a backupwww.sh para que los respalde:
#! /bin/bash
echo `date`
FILES=`ls -L /www`
for dir in $FILES
do
backupwww.sh $dir
done
echo `date`
exit 0
echo `date`
FILES=`ls -L /www`
for dir in $FILES
do
backupwww.sh $dir
done
echo `date`
exit 0
Luego backup.sh debe realizar el respaldo con rsync, primero revisa si existe public_html para ver si efectivamente este directorio pertenece a un sitio web,
luego usa rsync evitando la copia del directorio cache o templates_c, y borrando los archivos del destino que ya no esten en el origen:
backupwww.sh
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: ./backupwww.sh domain"
exit
fi
webdir=/www/$dominio/public_html
if [ -d $webdir ]; then
#echo WWW Backup: $1
rsync -a --exclude="cache/*" --exclude="templates_c/*" --delete /www/$1/ /backup/www/$1/
fi
if [ -z $1 ]; then
echo "Usage: ./backupwww.sh domain"
exit
fi
webdir=/www/$dominio/public_html
if [ -d $webdir ]; then
#echo WWW Backup: $1
rsync -a --exclude="cache/*" --exclude="templates_c/*" --delete /www/$1/ /backup/www/$1/
fi