What is rsync ?
-> According to wikipedia,
rsync is a utility for efficiently transferring and synchronizing files between a computer and an external hard drive and across networked computers by comparing the modification times and sizes of files. It is commonly found on Unix-like operating systems.
Basically it is a tool for sync to directory. Directories can be remote and local.
You can read more about it here. https://www.geeksforgeeks.org/rsync-command-in-linux-with-examples/
Please note the following behavior of rsync:
- Files that do not exist on the remote-host are copied.
- Files that have been updated will be synced, rsync will copy only the changed parts of files to the remote host.
- File that is exactly the same are not copied to the remote host at all.
Now,
To sync a folder locally use command
$ rsync -avh source destination
Here -avh is flag where a is for archived, v for verbose, h for human-readable format.
To sync a folder on a remote
$ rsync -avhze ssh source user@remote-host:destinationTo show progress of transfer
we can use --progress option.
$ rsync -avhze --progress ssh source user@remote-host:destination
To delete files which are not in source
we can use --delete option
$ rsync -avh --delete source destination
Performing a dry run
A dry run is a trial run. By using this we can get to know what happens if we run that command. Dry run doesn't make change to destination.
$ rsync -avh --delete --dry-run source destination
Comments
Post a Comment