mysql_backup_locally
This is an old revision of the document!
Mysql Backup Locally
- | mysqlbk.sh
#!/bin/sh DIR=<backup_directory> PW=<root_password> USER=<owner_of_file> DATE=$(date +%Y%m%d) mysqldump=$(which mysqldump) mysql=$(which mysql) tar=$(which tar) chown=$(which chown) for i in $($mysql -p$PW -e "SHOW DATABASES"|grep -v Database); do $mysqldump -p$PW --allow-keywords $i > $DIR/$i.sql done cd $DIR $tar -cvf $DATE.tar *.sql rm $DIR/*.sql $chown -R $USER $DIR exit 0
mysql_backup_locally.1241248319.txt.gz · Last modified: 2020/08/10 02:30 (external edit)