0% found this document useful (0 votes)
55 views14 pages

Syncing Folders with Rsync

Rsync is a tool for synchronizing files and directories between locations efficiently. It transfers only the differences in files to the destination, making it faster than other file transfer protocols. Rsync can synchronize files locally or remotely over SSH, compress data to reduce bandwidth usage, and delete files from the destination if they are removed from the source. It is commonly used for backups in UNIX/Linux systems.

Uploaded by

fooksin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views14 pages

Syncing Folders with Rsync

Rsync is a tool for synchronizing files and directories between locations efficiently. It transfers only the differences in files to the destination, making it faster than other file transfer protocols. Rsync can synchronize files locally or remotely over SSH, compress data to reduce bandwidth usage, and delete files from the destination if they are removed from the source. It is commonly used for backups in UNIX/Linux systems.

Uploaded by

fooksin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Rsync Rsync

What is What is rsync rsync??


rsync stands for remote sync.
rsync is used to perform the backup operation
in UNIX / Linux.
rsync is used to synchronize the files and
directories from one location to another in an
effective way.
Backup location could be on local server or on
remote server.
rsync stands for remote sync.
rsync is used to perform the backup operation
in UNIX / Linux.
rsync is used to synchronize the files and
directories from one location to another in an
effective way.
Backup location could be on local server or on
remote server.
Important features of Important features of rsync rsync
Speed: First time, rsync replicates the whole content
between the source and destination directories. Next
time, rsync transfers only the changed blocks or bytes
to the destination location, which makes the transfer
really fast.
Security: rsync allows encryption of data using ssh
protocol during transfer.
Less Bandwidth: rsync uses compression and
decompression of data block by block at the sending
and receiving end respectively. So the bandwidth used
by rsync will be always less compared to other file
transfer protocols.
Privileges: No special privileges are required to install
and execute rsync
Speed: First time, rsync replicates the whole content
between the source and destination directories. Next
time, rsync transfers only the changed blocks or bytes
to the destination location, which makes the transfer
really fast.
Security: rsync allows encryption of data using ssh
protocol during transfer.
Less Bandwidth: rsync uses compression and
decompression of data block by block at the sending
and receiving end respectively. So the bandwidth used
by rsync will be always less compared to other file
transfer protocols.
Privileges: No special privileges are required to install
and execute rsync
Basic Syntax Basic Syntax
rsync [options] [source] [destination]
Example Syntax Example Syntax
rsync -avz /root/test/ /home/test/
Option -a indicates archive mode and does the
following,
Recursive mode, preserves symbolic links,
preserves permissions, preserves timestamp,
preserves owner and group
Option -v indicates verbose mode
Option -z indicates enable compression
/root/test/ is the source directory
/home/test/ is the destination directory
Option -a indicates archive mode and does the
following,
Recursive mode, preserves symbolic links,
preserves permissions, preserves timestamp,
preserves owner and group
Option -v indicates verbose mode
Option -z indicates enable compression
/root/test/ is the source directory
/home/test/ is the destination directory
Notes on Notes on Option Option --zz
(Compressing the files while transferring them)
1. If we are transferring a large number of small
files over a fast connection, rsync may be slower
with the parameter -z than without it, as it will
take longer to compress every file before
transfer it than just transferring over the files.
2. Use this parameter if you have a connection
with limited speed between two computers, or
if you need to save bandwidth.
(Compressing the files while transferring them)
1. If we are transferring a large number of small
files over a fast connection, rsync may be slower
with the parameter -z than without it, as it will
take longer to compress every file before
transfer it than just transferring over the files.
2. Use this parameter if you have a connection
with limited speed between two computers, or
if you need to save bandwidth.
Use of "/" at the end of path: Use of "/" at the end of path:
1. When using "/" at the end of source, rsync will
copy the content content of the last folder.
2. When not using "/" at the end of source, rsync
will copy the last folder last folder and the content of the
folder.
3. When using "/" at the end of destination, rsync
will paste the data inside the last folder. inside the last folder.
4. When not using "/" at the end of destination,
rsync will create a folder create a folder with the last destination
folder name and paste the data inside that paste the data inside that
folder. folder.
1. When using "/" at the end of source, rsync will
copy the content content of the last folder.
2. When not using "/" at the end of source, rsync
will copy the last folder last folder and the content of the
folder.
3. When using "/" at the end of destination, rsync
will paste the data inside the last folder. inside the last folder.
4. When not using "/" at the end of destination,
rsync will create a folder create a folder with the last destination
folder name and paste the data inside that paste the data inside that
folder. folder.
rsync -avz source/ destination/
Use of "/" at the end of path: Use of "/" at the end of path:
rsync -avz source destination/
Use of "/" at the end of path: Use of "/" at the end of path:
Synchronizing two folders with Synchronizing two folders with rsync rsync
rsync -av --delete source/ destination/
1. To keep two folders in synchrony, not only do we need to
add the new files in the source folder to the destination
folder, as in the past topics, we also need to remove the
files that are deleted in the source folder from the
destination folder.
2. rsync allow us to do this with the parameter --delete, this
used in conjunction with the previously explained
parameter allow us to keep two directories in synchrony
while saving bandwidth.
1. To keep two folders in synchrony, not only do we need to
add the new files in the source folder to the destination
folder, as in the past topics, we also need to remove the
files that are deleted in the source folder from the
destination folder.
2. rsync allow us to do this with the parameter --delete, this
used in conjunction with the previously explained
parameter allow us to keep two directories in synchrony
while saving bandwidth.
Synchronizing Synchronizing files between two
remote systems
rsync -av --delete source/ destination/
source = username@server_IP:source/
e.g. [email protected]:/srv/www/htdocs/drupal/files/
destination = destination/
e.g. /srv/www/htdocs/drupal/files/
Synchronizing Synchronizing files between two
remote systems with encryption
rsync -e ssh -av --delete source/ destination/
Full Sync:
rsync -avz -u --progress --delete source/ destination/ -n
-a Archive mode
-v Verbose mode
-z
Compress while transferring files. This will
make the transferring faster and will save
the network bandwidth
Compress while transferring files. This will
make the transferring faster and will save
the network bandwidth
-u Update files which are newer in the Src
--progress
Show the transfer progress of each file
while transferring
--delete
Delete files fromDestination if they dont
exist in Source
-n
Preview mode. Changes wont take effect
till this argument is omitted
Rsync Rsync

You might also like