rsync — a fast, versatile, remote (and local) file-copying tool.
Some of the additional features of rsync are:
- support for copying links, devices, owners, groups, and permissions
- exclude and exclude-from options similar to GNU tar
- a CVS exclude mode for ignoring the same files that CVS would ignore
- can use any transparent remote shell, including ssh or rsh
- does not require super-user privileges
- pipelining of file transfers to minimize latency costs
- support for anonymous or authenticated rsync daemons (ideal for mirroring)
rsync [OPTION] [Source] [Destination]
[my-home@localhost ~]$ rsync -avz /home/my_home/mysql-11-10-2014.tar.gz /home/my-home/ sending incremental file list sent 66 bytes received 12 bytes 156.00 bytes/sec total size is 355212048 speedup is 4554000.62
[my-home@localhost ~]$ rsync -avz --progress /home/my_home/mysql-11-10-2014.tar.gz /home/my-home/ sending incremental file list rra-11-10-2014.tar.gz 355212048 100% 27.96MB/s 0:00:12 (xfer#1, to-check=0/1) sent 355331398 bytes received 31 bytes 28426514.32 bytes/sec total size is 355212048 speedup is 1.00
Explanation for the [options] used above:
-a = Archive mode.
-v = Be verbose.
-z = Compress the data during transfer.
–progress = Show progress during transfer.
Access via remote shell:
rsync can be used over ssh, making the transfer just as secure as other existing alternatives for secure transfer of remote data, such as scp & sftp. Since scp & sftp do not create incremental backups, and don’t sync the data between the source and the destination (but rather just copy the data, “as is”) – rsync should be preferred over these alternatives.
Pull: rsync [OPTION] [USER@]HOST:[Source] [Destination] Push: rsync [OPTION] [Source] [USER@]HOST:[Destination]
[my-home@localhost ~]$ rsync -avz -e ssh --progress email@example.com:/home/banjarnahor/backup/mysql/ /home/my-home/
Tip when got trouble:
[my-home@localhost ~]$ rsync -avz -e ssh --progress 111.xxx.xxx.xxx:/home/banjarnahor/backup/mysql/ /home/my_home/ ssh: connect to host 111.xxx.xxx.xxx port 22: Connection refused rsync: connection unexpectedly closed (0 bytes received so far) [receiver] rsync error: unexplained error (code 255) at io.c(600) [receiver=3.0.6]
check the port ssh from the source. like mine was 6969 and use –rsh=’ssh -p6969′.
[my-home@localhost ~]$ rsync -avz --rsh='ssh -p6969' --progress firstname.lastname@example.org:/home/banjarnahor/backup/mysql/ /home/my_home/ email@example.com's password: receiving incremental file list ./ mysql-11-10-2014.tar.gz 355212048 100% 4.14MB/s 0:01:21 (xfer#1, to-check=0/2) sent 33 bytes received 355331401 bytes 3800336.19 bytes/sec total size is 355212048 speedup is 1.00