Copy a File from a Remote Server to a Local Server with SSH
To specify a protocol with rsync you need to give “ -e” option with protocol name you want to use. Here in this example, We will be using “ssh” with “ -e ” option and perform data transfer.
[root@tecmint]# rsync -avzhe ssh [email protected]:/root/install.log /tmp/ [email protected]'s password: receiving incremental file list install.log sent 30 bytes received 8.12K bytes 1.48K bytes/sec total size is 30.74K speedup is 3.77
Copy a File from a Local Server to a Remote Server with SSH
[root@tecmint]# rsync -avzhe ssh backup.tar [email protected]:/backups/ [email protected]'s password: sending incremental file list backup.tar sent 14.71M bytes received 31 bytes 1.28M bytes/sec total size is 16.18M speedup is 1.10
Copy files from a Remote Server to a Local Server with SSH and exclude file (with dry run)
[root@tecmint]# rsync -avzhe ssh --dry-run --exclude-from '/tmp/exclude.txt' [email protected]:/backups/ /tmp/ [email protected]'s password: receiving file list ... done ./ packages sent 515 bytes received 111 bytes 46.37 bytes/sec total size is 12.28K speedup is 19.62
Source:
Slicehost: https://community.rackspace.com/products/f/public-cloud-forum/6655/migrating-a-linux-server-from-the-command-line—2
Tecmint: http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
I like this command:
rsync -av --progress ~/code/project-source/. ~/code/project-destination --exclude .git --exclude node_modules
Some of the commonly used options in rsync command are listed below:
-v, –verbose: Verbose output
-q, –quiet: suppress message output
-a, –archive: archive files and directory while synchronizing ( -an equal to following options -rlptgoD)
-r, –recursive: sync files and directories recursively
-b, –backup: take the backup during synchronization
-u, –update: don’t copy the files from source to destination if destination files are newer
-l, –links: copy symlinks as symlinks during the sync
-n, –dry-run: perform a trial run without synchronization
-e, –rsh=COMMAND: mention the remote shell to use in rsync
-z, –compress: compress file data during the transfer
-h, –human-readable: display the output numbers in a human-readable format
–progress: show the sync progress during transfer