Glam Prestige Journal

Bright entertainment trends with youth appeal.

How to backup MySQL database in a remote location using rsync?

I tried mysqldump but it is storing the backup in the local machine only. Also I need the backup files to be stored in tar format in the remote location.

Is there any way to combine rsync and mysqldump to store the backup in a remote system in tar format?

4

1 Answer

tar cannot create an archive with data received from standard input, so you must first dump the database and then tar it. To save space you can compress the dumped data on the fly.

Install mysql-client (apt-get install mysql-client) on the remote machine and run mysqldump from there:

mysqldump -h <server-hostname-or-ip-address> <options> <database-names> | bzip2 > dump-`date +%F-%H%M`.bz2

If you really need a tar archive, tar the bziped file:

tar cf <archive-name>.tar <bziped-dump>.bz2

or add it to an existent archive:

tar rf <pre-existent-archive-name>.tar <bziped-dump>.bz2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy