SCP: Synchronizes data, can be copied incrementally (same without overwriting)
Scp-r A/[e-mail protected]]ip:/b: Copy the files in directory A to directory B
Scp-r/root/10.10.10.26:/homt/champly/a/: If this
Install Scp:yum install-y openssh-clients on the other machine:
Then try the command again:
Results:
Remote server:
Local server:
Rsync: Synchronizing Data
rsync/directory 1/Directory 2: Synchronize local Directory
-A: Archive mode, which means that files are transferred recursively, and all properties are equal to-rlptgod, and the-a option can be followed by a--no-option, which indicates that one of the-rlptgod is closed, for example-a--no-l is equivalent to-rptgod (Must carry, inside with l,o,p,d,g)
-R: Subdirectories are processed in recursive mode, mainly for directories, if a single file is not required to add-r, but the transfer is the directory must be added to the-r option
-V: visual, print some information, such as rate, number of files, etc.
-L: Keep soft links (just copy linked files)
-L: When dealing with soft links like regular files, if there is a soft link file in src, then this option will copy the target file that the soft link points to DST (copy the real file)
-P: Keep file permissions
-P: Display speed
--bwlimit= Number: Limit transfer speed
-O: Keep file owner information
-G: Keep file group information
-D: Keep device file information
-T: Keep file time information
-Z: Compress and then pass, save bandwidth
-U: Anti-overwrite (skipped if backup file modified), not updated when the destination file is newer than the source file
--delete: Delete files in the source file that are not in the backup file
--exclude=pattern: Specifies to exclude files that do not need to be transferred, the equals sign followed by the file name, can be a universal character pattern (such as *.txt)
Eg:rsync-avl--exclude= "1.txt"--exclude= "2.txt"/root/champly//home/champly
Wildcard characters supported
rsync/directory 1 [email protected]:/directory 2: Synchronize the local directory to the remote
rsync [Email protected]:/directory 1/directory 2: Synchronize remote directories to local
If the SSH port number becomes 2200:
RSYNC-AVPL-E "ssh-p 2200" ip:/Directory/Directory
If you are logged on without a password, you can use the key
Strace: Can track process (yum install)
Rsync Application Example-Backend service mode:
Configuration file/etc/rsyncd.conf, with the following content:
#port the =873 #监听端口默认为873, or it could be another port.
Log File=/var/log/rsync.log #指定日志
PID File=/var/run/rsyncd.pid #指定pid
#address =192.168.0.10 #可以定义绑定的ip
The above section is the Global configuration section, the following are the settings within the module
[Test] #为模块名, custom
Path=/root/rsync # Specifies which directory the module corresponds to
Use Chroot=true #是否限定在该目录下, the default is true, when there is a soft connection, you need to change to Fasle
Max Connections=4 # Specifies the maximum number of clients that can be connected
Read Only=no #是否为只读
List=true #是否可以列出模块名, for safety reasons, is generally canceled.
Uid=root #以哪个用户的身份来传输
Gid=root #以哪个组的身份来传输
Auth Users=test #指定验证用户名, can not be set
Secrets file=/etc/rsyncd.passwd #指定密码文件, if you set the authentication user, this item must be set
Hosts allow=192.168.0.101 #设置可以允许访问的主机, can be a network segment
If you do not add the next two lines, you do not need to enter the password
The content format of the password file/etc/rsyncd.passwd is: Username:password, the permission is
The command to start the service is: Rsync–daemon
Default to use/etc/rsyncd.conf This configuration file, you can also specify the configuration file rsync--daemon--config=/etc/rsyncd2.conf
The available options are: Rsync–daemon--help
rsync ip::test:/directory 1/directory 2: Synchronizing data using the test module
Rsync-av--password-file=filename/Directory/directory: This can specify the password file, you can not enter
April 22, 2015
By:champly
Linux Learning Notes (System daily management-4)