Backup all databases in .gz format to location.
----------------------------------------------------------------------for db in `echo 'show databases;' | mysql | grep -v Database `; do mysqldump $db | gzip > /<backup_dir>/$db.sql.gz ; done
Backup all databases in .gz format to a remote location
-----------------------------------------------------------------------------------
for db in `echo 'show databases;' | mysql | grep -v ^Database ` ; do mysqldump --opt --single-transaction --quick $db | gzip -9 | ssh user@<Remote_IP_address> "cat > /home/<username>/<back_dir>/$db.sql.gz" ; done
NOTE: Make sure that key authentication is enabled b/w the servers.
0 comments:
Post a Comment