Background
rsync is powerful and easy to use utility to keep files in sync between two servers. The principal way of rsync‘s command structure is to push files from point A to point B.
A Basic Example of an
rsync
Command
rsync -vzru /home/location_A/ user@server2.example.com:/home/location_B/
In the command above, files from
on a local disk and server is `pushed` to
on
.
The flags means the following:
The
is really useful because it means all directories and subdirectories will be copied.
means that it won’t copy files again which are the same as the destination receiver
Rsync Example with Custom SSH Port and Preserve Directory Permissions and Attributes
rsync -vrzua -e 'ssh -p 34229' /home/location_A/ user@server2.example.com:/home/location_B/
In the above example, two additional flags were added, namely
and
. These means:
The
switch is extremely useful as it will copy all the attributes, e.g. directory permissions and so on.
Using
rsync
in Real Time
Typically
commands are stored in a
to run every XX minutes.
If you want continuous
, and you are well aware of what it’s going to do to your network traffic, then you need to use an utility called
because running one
if the previous one hasn’t completed will cause problems.
Here is an example of the flock command:
References
produces: