Rsync Tools
The Rsync tool is used to synchronize folder data, unlike the CP command, which can handle real-time changes in files, synchronizing source and target data directories, and not processing the same portion of data for two directories.
I. SUMMARY OF TOOLS
Command wording
The next SRC is the abbreviation of source, dest is the abbreviation of destination
rsync-Option Source directory path (target host user name) @ Destination IP address: Destination directory path
Rsync-Options ... src [src] ... Target path
Rsync-Options ... src [src] ... [[email protected]] Host:dest
Rsync-Options ... src [src] ... [[email protected]] HOST::D EST
Rsync-Options ... src [src] ... rsync://[[email protected]]host[:P ort]/dest
Rsync-Options ... [[email protected]] HOST:SRC [DEST]
Rsync-Options ... [[email protected]] HOST::SRC [DEST]
Rsync-Options ... rsync://[[email protected]]host[:P ort]/src [DEST]
Command common options
-A equals to-rtplgod
-R to copy directory, like the-r option when CP
-V detailed synchronization details, let us know the process of synchronization
-L Keep Soft links
-L with this option, the source files are synchronized when the soft link is synchronized
-P Keep File permissions property
-O Keep File owner
-G hold File group
-D Keep Device file information
-T keep file Time properties
--delte Delete files in dest that are not in SRC
--exclude filter the specified file, such as--exclude "logs" will be the file name contains logs files or directories filtered out, not synchronized
-P shows the synchronization process, such as rate, more detailed than-V
-U plus this option, if the files in the target directory are newer than the original directory, the sync
-Z Compression during transfer
Example of an action command:
Points:
1. The "/" symbol must be added at the end when synchronizing folders
2, focus on understanding-a-delte-exclude-u four options
Ii. Examples of rsync command operations
1. Back up the passwd file to a local/tmp/pswd.bak
Rsync-ap/etc/passwd/tmp/pswd.bak
2. Back up the passwd file to 100.100/tmp/208.128.bak
rsync-ap/etc/passwd [Email Protected]:/tmp/208.128.bak
Third, synchronize the folder through SSH
3, configure Authorized_key to achieve free login synchronization
1. Generate SSH key pair
Ssh-keygen
2. Distribute SSH keys to the backup machine
Ssh-copy-id [email protected]
3. Test results
rsync-ap/etc/passwd [Email Protected]:/tmp/208.128.bak
Iv. directory synchronization through the service
Linux System Management Preliminary (eight) data Backup tool rsync