User Tools

Site Tools


backup_mysql_database_script

Backup_mysql_database_script

 #!/bin/bash
 # Created by Bryan Le Gear - Skynet 2005/10/12
 #
 # This script must be run by dbadmin
 # and this user must have the root password
 # configured in ~/.my.cnf
 #
 <br>
 COMPRESS=gzip
 MYSQLDUMP=mysqldump
 MYSQLDUMP_ARGS="-u root -p --lock-tables=false --all-databases"
 CURRDATE=`date +%d-%m-%Y`
 BACKUPDIR=/home/backup
 OUTFILE=$BACKUPDIR/mysqlbackup_$CURRDATE.sql.gz
 
 echo 
 echo "Backing up to:     " $OUTFILE
 echo "Compressing using: " $COMPRESS
 $MYSQLDUMP $MYSQLDUMP_ARGS | $COMPRESS > $OUTFILE 
 
 echo "Chmoding to:         400"
 chmod 400 $OUTFILE
backup_mysql_database_script.txt · Last modified: 2022/07/20 22:06 by admin