Move database files from one server to another

I like to use scp to transfer files of a database from one box to another, then follow-up with an rsync.

this is how I do it:

sudo rsync -avz /source/path/* user@boxname:/destination/path/

Lets break it down:

 

-a, or –archive  

This is equivalent to -rlptgoD. It is a quick way of saying you
want recursion and want to preserve almost everything (with -H
being a notable omission). The only exception to the above
equivalence is when –files-from is specified, in which case -r
is not implied.

-v, or –verbose 

This option increases the amount of information the daemon logs
during its startup phase. After the client connects, the daeâ
monâs verbosity level will be controlled by the options that the
client used and the “max verbosity” setting in the moduleâs conâ
fig section.

-z, or –compress

With this option, rsync compresses the file data as it is sent
to the destination machine, which reduces the amount of data
being transmitted â something that is useful over a slow connecâ
tion.Note that this option typically achieves better compression
ratios than can be achieved by using a compressing remote shell
or a compressing transport because it takes advantage of the
implicit information in the matching data blocks that are not
explicitly sent over the connection.

__________________________________________________

If the database is really large, or if your connecition to the shell is bad also consider

 

sudo nohup  rsync -avz /source/path/* user@boxname:/destination/path/

 

NOHUP

nohup – run a command immune to hangups, with output to a non-tty


Posted in Linux, MySQL, SQL

Leave a Reply