Linux Study Notes (daily System Management-4)
Scp: synchronous data, which can be incrementally copied (identical but not overwritten)
Scp-r a/[root @] ip:/B: copy the files in directory a to directory B.
Scp-r/root/10.10.10.26:/homt/champly/a/: If this
Then install scp: yum install-y openssh-clients on the target machine:
Run the following command again:
Result:
Remote Server:
Local Server:
Rsync: synchronize data
Rsync/directory 1/directory 2: synchronize local directories
-A: Archive mode, indicating that the file is transmitted recursively and all attributes are kept, which is equivalent to-rlptgoD, -The end of OPTION a can be followed by a -- no-OPTION which indicates to disable-rlptgoD. For example,-a -- no-l is equivalent to-rptgoD.(It must contain l, o, p, D, g)
-R: The subdirectories are processed in recursive mode, mainly for directories. If you upload a file separately, you do not need to add-r, but you must add the-r option to the directory.
-V: It is visible and prints some information, such as the speed and number of files.
-L: retain soft links (just copy the linked files)
-L: process soft links like regular files. If SRC contains soft link files, with this option added, the target file to which the soft link points will be copied to DST (copy the real file)
-P: Keep File Permissions
-P: display speed
-- Bwlimit = Number: limit transmission speed
-O: Keep file owner information
-G: Keep file group information
-D: Keep the Device File Information
-T: Keep file time information
-Z: compress data before transmission, saving bandwidth
-U: Protection against overwriting (if the backup file is modified, it will be skipped) and will not be updated when the target file is newer than the source file.
-- Delete: delete files in the source files that are not backed up.
-- Exclude = PATTERN: Specifies to exclude files that do not need to be transmitted. The equal sign is followed by the file name. It can be a-Character Mode (for example, *. txt)
Eg: rsync-avL --exclude1_1_1.txt "--exclude1_2.txt"/root/champly // home/champly
Wildcard characters are supported.
Rsync/directory 1 username @ ip:/directory 2: Synchronize the local directory to the remote
Rsync username @ ip:/directory 1/directory 2: Synchronize the remote directory to the local
If the ssh port number is changed to 2200:
Rsync-avPL-e "ssh-p 2200" ip: // directory/directory
If you do not need a password to log on, you can use the key
Strace: process tracing (yum install)
Rsync application instance-Background Service method:
The configuration file/etc/rsyncd. conf is as follows:
# Port = 873 # The default listening port is 873 or another port.
Log file =/var/log/rsync. log # specify the log
Pid file =/var/run/rsyncd. pid # specify the pid
# Address = 192.168.0.10 # The bound ip address can be defined.
The above section is the global configuration section. The following section describes the settings in the module.
[Test] # custom Module name
Path =/root/rsync # specify the directory in which the module is located
Use chroot = true # whether it is limited to this directory. The default value is true. If there is a soft connection, change it to fasle.
Max connections = 4 # specify the maximum number of clients that can be connected
Read only = no # whether it is read-only
List = true # Whether the module name can be listed. It is generally canceled for security reasons.
Uid = root # which user is used for transmission?
Gid = root # ID of the group used for transmission
Auth users = test # specify the authentication username, which can be left empty
Secrets file =/etc/rsyncd. passwd # specify the password file. If the user is verified, this item must be set
Hosts allow = 192.168.0.101 # Set the host that can be accessed, which can be a network segment
If you do not add the last two lines, you do not need to enter the password.
The password file/etc/rsyncd. passwd is in the format of username: password,The permission is 600.
The command to start the service is: rsync-daemon
By default, the configuration file/etc/rsyncd. conf is used. You can also specify the configuration file rsync -- daemon -- config =/etc/rsyncd2.conf.
Available options: rsync-daemon -- help
Rsync ip: test:/directory 1/directory 2: Use the test module to synchronize data
Rsync-av -- password-file = filename/directory: You can specify the password file without entering
April 22, 2015
By: champly