====== Ubuntu - RSync - Rsync over ssh ======
With a proper **~/.ssh/config** file and port and user and ip can be filled in too, so you don't need to complicate any ssh-based connection with it again.
rsync -rltDvz remote-box:/home/usr/Projects/ /backups/storage-mnt/Projects/
Add this stanza to the **~/.ssh/config**:
host remote-box
user usr
hostname 192.168.10.21
port 12345
That same setup will be used for ssh, scp, sftp, rdiff-backup, x2go, or any other ssh-based connection where the hostname goes in the command.
No more trying to recall -p or -P or what the alternate username is on some remote system or what the IP is if you can't recall.
The hostname can be an IP, DNS or /etc/hosts entry.
Tab completion for those commands knows to check this config file too.
----
from the Server, this command will pull binary changes while leaving ownership, group, & permission syncing out.
rsync -rltDvz -e "ssh -p 12345" usr@192.168.10.21:/home/usr/Projects/ /backups/storage-mnt/Projects/
This command leaves ownership, group, & permissions unchanged on destination and only syncs the binary data.
To pull over the desktop credentials **-a** could also be used.
But instead with **-rltDvz** changed files come over and inherit the permissions of the original files on the Server.
Remember that new files/directories created on the desktop will have the desktop user credentials which do not necessarily are what is used on the remote server. This is fixed after the rsync by using a careful chmod on those specific new files that pulled over.
I could chown the destination directory back to root:root if I want but for this directory the standard user:user is fine, especially since I always leave my backup drives umounted until I need to do a retrieval or backup.