linux backup script mysql gzip dump

Челябинская область

Автор:Dmitriy Altuhov

linux backup script mysql gzip dump

#!/bin/sh

mount /dev/sdb1 /mnt/sdb1

if [ $(ls /mnt/sdb1/backup/*.dump.gz | wc -l) -gt 8 ]
then
  find /mnt/sdb1/backup/*.dump.gz -mtime +8 -delete 2>/dev/null > /dev/null
fi
DIR=»/mnt/sdb1/backup»
#mkdir -p $DIR
#LOG=»/backup/log/log.log»
#touch $LOG
TIMENAME=`date +%d.%m.%Y-%H.%M`
db=`mysql -u root -h localhost -pPASS -Bse ‘show databases’`
for n in $db; do
#TIMEDUMP=`date ‘+%T %x’`
#echo «backup has been done at $TIMEDUMP : $TIMENAME on db: $n» >> $LOG
mysqldump -u root -h localhost -pPASS $n | gzip -c > «$DIR/mysql-$n-$TIMENAME-db.dump.gz»
done
umount /mnt/sdb1
Comments Are Closed!!!