Tagged with: Linux rsync data Sync rsync detailed
rsync command
Rsync has six different modes of operation:
1) Copy the local file. This mode of operation is initiated when both the SRC and des path information do not contain a single colon ":" delimiter.
Rsync-a/data/backup
2) Use a remote shell program (such as rsh, SSH) to copy the contents of the local machine to the remote machine. This mode is started when the DST path address contains a single colon ":" delimiter.
Rsync-avz *.c FOO:SRC
3) Use a remote shell program (such as rsh, SSH) to copy the contents of the remote machine to the local machine. This mode is started when the SRC address path contains a single colon ":" delimiter.
Rsync-avz Foo:src/bar/data
4) Copy files from the remote rsync server to the local machine. This mode is started when the SRC path information contains the "::" delimiter.
Rsync-av [Email Protected]::www/databack
5) Copy files from the local machine to the remote rsync server. This mode is started when the DST path information contains the "::" delimiter.
rsync-av/databack [Email protected]::www
6) The list of files for the remote machine is listed. This is similar to the rsync transfer, but only if the local machine information is omitted from the command.
Rsync-v rsync://192.168.1.2/www
The specific explanations for the rsync parameters are as follows:
-V,--verbose verbose mode output
-Q,--quiet thin output mode
-C,--checksum turn on the check switch to force verification of file transfers
-A,--archive archive mode, which means to transfer files recursively and keep all file attributes equal to-rlptgod
-R,--recursive subdirectories in recursive mode
-R,--relative using relative path information
-B,--backup creates a backup, that is, the old file is renamed to ~filename when the same file name exists for the purpose. You can use the--suffix option to specify a different backup file prefix.
--backup-dir store backup files (such as ~filename) in the directory.
-suffix=suffix Defining backup File prefixes
-U,--update only updates, which is to skip all the files that already exist in DST, and the file time is later than the file to be backed up. (Does not overwrite the updated file)
-L,--links reserved Soft link
-L,--copy-links to handle soft links like regular files
--copy-unsafe-links only copies links to links outside the SRC Path directory tree
--safe-links ignoring links to the SRC Path directory tree
-H,--hard-links reserved Hard link
-P,--perms maintain file permissions
-O,--owner keep file owner information
-G,--group keep file group information
-D,--devices keep device file information
-T,--times keep file time information
-S,--sparse special processing of sparse files to save DST space
-N,--dry-run reality which files will be transmitted
-W,--whole-file copy files without incremental detection
-X,--one-file-system do not cross file system boundaries
-B, the block size used by the--block-size=size test algorithm, is 700 bytes by default
-E,--rsh=command specifies data synchronization using RSH and SSH
--rsync-path=path Specify the path information for the rsync command on the remote server
-C,--cvs-exclude uses the same method as CVs to automatically ignore files to exclude files that you do not want to transfer
--existing only updates those files that already exist in DST without backing up those newly created files
--delete Delete those files that are not in the DST SRC
--delete-excluded also deletes those files that are excluded by the option specified by the Receive side
--delete-after transfer ends after removal
--ignore-errors timely IO errors are also deleted
--max-delete=num deleting NUM files up to a maximum
--partial retains files that are not fully transmitted for any reason, to expedite subsequent transmissions
--force forcibly delete a directory, even if it is not empty
--numeric-ids does not match the user and group ID of a number to a user name and group name
--timeout=time IP time-out, in seconds
-I ,--ignore-times do not skip files that have the same time and length
--size-only when deciding whether to back up a file, just look at the file size regardless of file time
--modify-window=num determines whether the file is time-stamped with the time Stamp window, which defaults to 0
-t--temp-dir=dir creating temporary files in Dir
--compare-dest=dir also compares the files in DIR to determine if a backup is required
-p equivalent to--partial
--progress Show Backup Process
-Z,--compress compress the backed-up files during transmission
--exclude=pattern Specify to exclude file modes that do not need to be transferred
--include=pattern specifies file modes that need to be transferred without exclusion
--exclude-from=file exclude files in the specified schema in file
--include-from=file does not exclude files that specify pattern matching
--version Print version Information
--address binding to a specific address
--config=file specify a different configuration file, do not use the default rsyncd.conf file
--port=port Specify a different rsync service port
--blocking-io using blocking IO for remote shells
-stats gives the transfer status of some files
--log-format=format specifying the log file format
--password-file=file get the password from file
--bwlimit=kbps limit I/O bandwidth, Kbytes per second
-H,--help display Help information
Generally use the AZV option (this parameter is not recommended if Windows is synchronized with Linux)
Rsync Data Synchronization Instance
Synchronize directly with commands
RSYNC-VZRTOPG--progress-e ssh--delete [email protected]:/www/*/databack/www
This is the direct use of the-e SSH synchronization data, you can directly synchronize the data over any machine is not set to the server side
sync-avpz-e ssh 192.168.1.100:/' find/home-name "*.sh" '/backupdir
This command will find all the *.sh files in/home and its subdirectories, and will be divided into the/backupdir directory
No password server-side synchronization configuration
Service side: vim/etc/rsyncd.conf
#This is the rsync daemon configuration
#global settings
PID file =/var/run/rsyncd.pid
Port = 873lock File =/var/run/rsyncd.lock
Log file =/var/log/rsync.log
GID = root
UID = root
#module settings
[Data]
Path =/web/rsync/data
Use chroot = no
Max connections = 15read only = Yeswrite only = no
List = no
Ignore errors = yes
Timeout = 120
/usr/bin/rsync--daemonmkdir-p/web/rsync/data
Client
Rsync-avz--progress [email protected]::d ata/home/hadoop/data
Limit traffic synchronization
Rsync-avz--bwlimit=100--progress [email protected]::d ata/home/hadoop/data
There is a password server-side synchronization configuration
Vim/etc/rsyncd.conf
#This is the rsync daemon configuration
#global settings
PID file =/var/run/rsyncd.pid
Port = 873lock File =/var/run/rsyncd.lock
Log file =/var/log/rsync.log
GID = root
UID = root
#module settings
[Auth_data]
Path =/web/rsync/auth_data
Use chroot = no
Max connections = 15read only = Yeswrite only = no
List = no
Ignore errors = yes
Timeout = 120auth users = Hadoop
Secrets file =/etc/rsyncd.passwd
echo "hadoop:password123" >/etc/rsyncd.passwd chmod 600/etc/rsyncd.passwdmkdir-p/web/rsync/auth_data
Client
echo "password123" >/home/hadoop/rsyncd.passwd chmod 600/home/hadoop/rsyncd.passwd
Rsync-avz--progress--password-file=/home/hadoop/rsyncd.passwd [email protected]::auth_data/home/hadoop/auth_data
Write synchronization configuration
Vim/etc/rsyncd.conf
#global settings
PID file =/var/run/rsyncd.pid
Port = 873lock File =/var/run/rsyncd.lock
Log file =/var/log/rsync.log
GID = root
UID = root
#module settings
[Write_data]
Path =/web/rsync/write_data
Use chroot = no
Max connections = 15read only = no
List = no
Ignore errors = yes
Timeout = 120auth users = Hadoop
Secrets file =/etc/rsyncd.passwd
Mkdir-p/web/rsync/write_data
Client
echo "123" >/home/hadoop/write_file
Export rsync_password= "password123" Rsync-avz--progress--delete/home/hadoop/write_file [email protected]::write_ Data
Limit IP or network segment synchronization configuration
#global settings
PID file =/var/run/rsyncd.pid
Port = 873lock File =/var/run/rsyncd.lock
Log file =/var/log/rsync.log
GID = root
UID = root
#module settings
[Write_data]
Path =/web/rsync/write_data
Use chroot = no
Max connections = 15read only = no
List = no
Ignore errors = yes
Timeout = 120auth users = Hadoop
Secrets file =/etc/rsyncd.passwdhosts allow = 192.168.1.3 192.168.1.0/24
This article is from the "Practical Linux knowledge and Skills sharing" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1888060
Linux rsync Data Synchronization command parsing