====== Rsync ======
Syntax:
rsync -ave ssh user@server:source destination
Example:
rsync -ave ssh user@server:/home/steviewdr/public_html /home/steviewdr/
#or
rsync -ave "ssh -p 2222" /home/user/folder/ username@remotedestinationserver:/home/user/folder/
====== Scenario - Migrating MySQL Server ======
Recently migrating a MySQL Server. We had a new one setup. There was ~8GB of data in /var/lib/mysql needing to be sync'd.
Option A: shutdown mysql and copy across /var/lib/mysql
Option B: Use rsync to sync the data. That way, downtime would only take 1-2 minutes (to resync latest modified files etc.
===== rsync switches used for sync =====
#ssh into current mysql server, and run:
rsync -avPin --delete /var/lib/mysql newhost:/var/lib/
a = archive (equals -rlptgoD for recursive, group, owner, permissions etc.)
v = verbose
P = progress
i = itemise changes
n = dry run (remove the n, for the proper run)
--delete = delete files on target, which were deleted on host since last run.
After than runs. Stop MySQLd on current server, and run the same rsync again.