The following image contains the syntax for rsync.
--verbose --progress --stats
These options allow you to view the status of the data transfer.
This option tells rsync to use compress during the transfer.
This option tells rsync to use the secure shell to transfer the data and the path to find the ssh utility.
This option tells rsync to follow the source pathname, recursively transferring files that have been added or altered.
These options preserve the file timestamps and permissions.
/files/* /files/* specifies which local filesystem rsync should transfer files from for transmission to the remote rsync server.
fileserver: fileserver should be the DNS name or IP address of your rsync server. It is important that you only use one colon to separate the
DNS name for the path. Otherwise, rsync will use rsh to perform the transfer instead of ssh.
rsync_server_path_name rsync_server_path_name specifies the path the files should be transferred to on the rsync server.
The rsync tool is another way to securely copy files from one system to another. It differs from scp in that if two files or directories are similar between two systems,
rsync only needs to copy the differences between the systems, while scp would need to copy everything. One of the advantages of rsync is that it can copy files between a local system and a remote system securely and efficiently. While the initial synchronization of a directory takes about the same time as copying it, any subsequent synchronization only requires the differences to be copied over the network.
One of the most important options of rsync is the -n option to perform a dry run. A dry run is a simulation of what happens when the command really gets executed. It will display the changes to be performed when the command is executed without the dry run option. It is recommended to perform a dry run of any rsync operation to ensure that no important files get overwritten or deleted.
The two most common options when synchronizing files and folders with rsync are the -a and - v options. While the -v option adds verbosity to the output as the synchron ization proceeds, the -a option stands for "archive mode" and enables the following options all in one:
- r: synchronize recursively the whole directory tree
-1: synchronize symbolic links
- p: preserve permissions
- t: preserve time stamps
-g: preserve group ownership
- o: preserve the owner of the files
-D: synchronize device files
While the -a already synchronizes symbolic links, there are additional options necessary to preserve hardlinks, as they are treated as separate files instead. The -H option enables the handling of hardlinks, so the rsync command will identify the hardlinks present in the source folder and link the files accordingly in the destination folder instead of just copying them as separate files.