MySQL Backup
#!/bin/bash USERNAME="root" PW="pass" BACKUPDIR=/crew/data/backup DBDIR=/crew/data/backup/DB MYSQLDIR=/var/lib/mysql rm $DBDIR/*.sql `mv $BACKUPDIR/sql.tar.gz $BACKUPDIR/sql.tar.gz.1` `mv $BACKUPDIR/sql.md5 $BACKUPDIR/sql.md5.1` for DB in $MYSQLDIR/*; do DB=`basename $DB` mysqldump -c -e -a -B $DB -u $USERNAME -p$PW > $DBDIR/$DB.sql echo "$DB is dumped..." done tar -zvcf $BACKUPDIR/sql.tar.gz $DBDIR 1> /dev/null rm $DBDIR/*.sql `/usr/bin/md5sum $BACKUPDIR/sql.tar.gz > $BACKUPDIR/sql.md5`