MySQL Backup

From Frotmail Projects
Revision as of 09:26, 5 April 2022 by Eric (talk | contribs) (Created page with " #!/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 $BACKUPDI...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#!/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`