Search Engine

Loading

Sallar

Sallar
RedhatEnterpriseLinux Blog

The rsync Utility


The rsync Utility
When developing backup scripts, consider using the rsync utility. The rsync utility allows you to copy from the local system to a remote system or copy between two local directories. If the files exist in the destination directory, rsync only transfers the differences in the files, which is ideal for backups. The rsync RPM package is required and should already be installed on your system.
After the rsync command-line arguments are listed, the first directory listed is the source, and the second directory listed is the destination. If either directory is preceded by a hostname and a colon (:), the directory is a remote directory. For example, to transfer all home directories to the backup/ directory on the remote server backup.example.com:


rsync -avz /home backup.example.com:backups/

The -a argument stands for “archive” mode, meaning that rsync performs a recursive transfer (the source directory, its subdirectories, the subdirectories of the subdirectories, and so on are transferred), symbolic links are preserved, permissions and time stamps are preserved, groups are preserved, file ownership is preserved if it is root, and devices are preserved if they are owned by root. If the -v argument is used, progress messages are displayed including how much data is sent and received and the average transfer rate.
Using the -z argument compresses the data to be transferred, speeding up the time it takes to transfer the files or the file differences.
When transferring files with rsync, whether or not a trailing slash is included on the source directory is important. In our example, a trailing slash is not used on the source directory so that the directory backups/home/ is created on the remote server and all the files in the /home/ directory on the local system are recursively copied into backups/home/ on the remote server. If a trailing slash is specified on the source directory such as the following:

rsync -avz /etc/sysconfig/ backup.example.com:backups/configfiles/

The source directory specified is not created in the destination directory. In our example, all the files in /etc/sysconfig/ on the local system are recursively copied into the backups/configfiles/ directory on the remote server.

0 comments:

Post a Comment

Powered by Blogger.

Ads

 
Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: www.redhatenterpriselinux.blogspot.com I live in Quetta, Pakistan and work as an IT-Engineer.