Jove
17/03/2009, 16:34
Hola,
Muchas gracias, lo probaré.
Saludos
Muchas gracias, lo probaré.
Saludos
¿Más ideas?
#!/bin/bash
# full and incremental backup script
# created 07 February 2000
# modified 06 March 2009
# Based on a script by Daniel O'Callaghan
# and modified by Gerhard Mourani
# and by Alvaro Remesal
#Change the 5 variables below to fit your computer/backup
COMPUTER=r0000.ovh.net # name of this computer
DIRECTORIES="/home/admin/www /etc" # directories to backup
BACKUPDIR=/home/admin/backups # where to store the backups
TIMEDIR=/home/admin/backups/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar
BACKUPDBDIR=/home/admin/www/bbdd # temporal para almacenar backup de bbdd
LOG=/home/admin/backup-$(date +%d%m%y).log # archivo para el log
#You should not have to change anything below here
PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep
# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.
# If you'll execute for first time, you should create the timedate file
# To do this, just execute:
# date +%d%b < /home/admin/backups/last-full/myserver-full-date
# Where myserver = name of the computer
echo -e "\nBackup iniciado: `date`" >> $LOG
# Databases backup
for bd in `mysqlshow -uUUUU -pPPPP | grep \| | grep -v Databases | sed -e s/\|//g` ; do
mysqldump -uUUUU -pPPPP --opt $bd > $BACKUPDBDIR/$bd.sql
echo -e "\nDump de $bdG" >> $LOG
done
# Monthly full backup
if [ $DOM = "01" ]; then
NEWER=""
echo -e "\nIniciado mensual completo... " >> $LOG
$TAR $NEWER -zcf $BACKUPDIR/$COMPUTER-$DM.tar.gz $DIRECTORIES
echo -e "\nMensual completo terminado " >> $LOG
fi
# Weekly full backup
if [ $DOW = "Sun" ]; then
NEWER=""
NOW=`date +%d-%b`
echo -e "\nIniciado semanal completo... " >> $LOG
# Update full backup date
echo $NOW > $TIMEDIR/$COMPUTER-full-date
$TAR $NEWER -zcf $BACKUPDIR/$COMPUTER-$DOW.tar.gz $DIRECTORIES
echo -e "\nFinalizado semanal completo" >> $LOG
# Make incremental backup - overwrite last weeks
else
# Get date of last full backup
echo -e "\nIniciado incremental diario... " >> $LOG
NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`"
$TAR $NEWER -zcf $BACKUPDIR/$COMPUTER-$DOW.tar.gz $DIRECTORIES
echo -e "\nFinalizado incremental diario " >> $LOG
fi
echo -e "\n --- Backup finalizado --- " >> $LOG
for bd in `mysqlshow -uUUUU -pPPPP | grep \| | grep -v Databases | sed -e s/\|//g` ; do
mysqldump -uUUUU -pPPPP --opt $bd > $BACKUPDBDIR/$bd.sql
for bd in `mysqlshow -uroot -pMiPass | grep \| | grep -v Databases | sed -e s/\|//g` ; do
mysqldump -uroot -pMiPass --opt $bd > $BACKUPDBDIR/$bd.sql