How to Use rsync in Linux for data backup, linuxrsync
For various organizations and companies, data is the most important to them. Even for e-commerce, data is equally important. Rsync is a tool/software that backs up important data through the network. It is also a network protocol for synchronizing folders and files between systems through the network on Unix-like and Window systems. Rsync can copy or display directories and copy files. Rsync listens to TCP port 873 by default and Copies files through remote shell such as rsh and ssh. Rsync must be installed on both the remote and local systems.
how to speed up rsync transfers
The main advantages of rsync are:
Speed: All content will be copied locally and remotely. Next time, only the changed block or byte will be transmitted.
Secure: data can be encrypted over ssh.
speed up rsync
Low bandwidth: rsync can compress and decompress data blocks at both ends.
Syntax:
speed up rsync many small files
#rsysnc [options] source path destination path
Example: 1-enable Compression
[root@localhost /]# rsync -zvr /home/aloft/ /backuphomedir
building file list ... done
.bash_logout
.bash_profile
.bashrc
sent 472 bytes received 86 bytes 1116.00 bytes/sec
total size is 324 speedup is 0.58
The preceding rsync command uses-z to enable compression.-v is visualized and-r is recursive. The above is synchronized between the local/home/aloft/AND/backuphomedir.
Example: 2-Preserve the attributes of files and folders
[root@localhost /]# rsync -azvr /home/aloft/ /backuphomedir
building file list ... done
./
.bash_logout
.bash_profile
.bashrc
sent 514 bytes received 92 bytes 1212.00 bytes/sec
total size is 324 speedup is 0.53
We used the-a option above, which retains the owner and group, timestamp, soft link, and permission and runs in recursive mode.
Example: 3-synchronize local data to a remote host
root@localhost /]# rsync -avz /home/aloft/ azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/
Password:
speed up rsync large files
building file list ... done
./
.bash_logout
.bash_profile
.bashrc
sent 514 bytes received 92 bytes 1212.00 bytes/sec
total size is 324 speedup is 0.53
The preceding command allows you to synchronize data between local and remote machines. As you can see, you are prompted to enter the password when Synchronizing files to another system. During remote synchronization, you must specify the user name and IP address or Host Name of the remote system.
Example: 4-remote synchronization to local
[root@localhost /]# rsync -avz azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/ /home/aloft/
Password:
building file list ... done
./
.bash_logout
.bash_profile
.bashrc
sent 514 bytes received 92 bytes 1212.00 bytes/sec
total size is 324 speedup is 0.53
The preceding command synchronizes remote files to the local device.
Example: 5-find out the differences between files
[root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/
building file list ... done
cd+++++++ backuphomedir/
>f+++++++ backuphomedir/.bash_logout
>f+++++++ backuphomedir/.bash_profile
>f+++++++ backuphomedir/.bashrc
>f+++++++ backuphomedir/abc
>f+++++++ backuphomedir/xyz
sent 650 bytes received 136 bytes 1572.00 bytes/sec
total size is 324 speedup is 0.41
The above command helps you find out the differences between the source address and the target address in the file or directory.
Example: 6-Backup
The rsync command can be used to back up linux.
You can use rsync in cron to schedule backups.
0 0 * * * /usr/local/sbin/bkpscript &> /dev/null
vi /usr/local/sbin/bkpscript
rsync -avz -e ‘ssh -p2093′ /home/test/ root@192.168.1.150:/oracle/data/
Via: http://linoxide.com/how-tos/rsync-copy/