10.29/10.30 Rsync common options”
option | Meaning |
---|---|
-a | Include -rtplgoD |
-r | When you synchronize the directory, add the -r option similar to CP. |
-v | Synchronize display some information, let us know the process of synchronization. |
-l | Soft connection reserved |
-L | With this option, synchronization of the source files will be synchronized when the soft links are synchronized. |
-p | Keep file permission attributes |
-o | Keep the file owner. |
-g | Maintain file group |
-D | Keep device file information. |
-t | Keep file time attributes |
–delete | Delete files that SRC does not have in DEST |
–exclude | Filtering specified files, such as — exclude “logs” filters out files or directories whose filenames contain logs, out of sync |
-P | Display synchronization process, such as speed, more detailed than -v. |
-u | With this option, if files in DEST are new than SRC, they are not synchronized. |
-z | Transmission time compression |
-l Soft connection
[root@localhost 111]# ls -l
lrwxrwxrwx. 1 root root 11 8Month 31 19:55 passwd.l -> /etc/passwd[root@localhost 111]# Rsync -av /root/111/ /tmp/111_destSendIng incremental file listCreated directory /tmp/111_dest.Passwd.l -> /etc/passwdSent 388 byTES received 153 bytes 1082 bytes/secTotal size is 11 speedup is 0.02[root@localhost 111]#Ls -l /tmp/111_dest/Lrwxrwxrwx. 1 root root 118 month 31 19:55 passwd.l -> /etc/passwd
-L With this option, synchronization of the source files will be synchronized when the soft links are synchronized.
[root@localhost 111]# ls -l
lrwxrwxrwx. 1 root root 11 8Month 31 19:55 passwd.l -> /etc/passwd[root@localhost 111]# Rsync -avL /root/111/ /tmp/111_destSenDing incremental file listPasswd.lSent 1060 bytes received 35 bytes 2190 bytes/secTotal SIze is 846 speedup is 0.77[root@localhost 111]# LS -l /tmp/111_dest/-rw-r--r--. 1 root root 8467Month 27 05:17 passwd.l
–delete Delete files that SRC does not have in DEST
[root@localhost 111]# ls
1.txt 2.txt 3.txt aaa.txt a.txt passwd.l
[root@localhost 111]# ls /tmp/111_dest/
1.txt 2.txt 3.txt aaa.txt a.txt passwd.l
[root@localhost 111]# touch /tmp/111_dest/cde.txt
[root@localhost 111]# rsync -av --delete /root/111/ /tmp/111_dest
sending incremental file list
deleting cde.txt
sent 193 bytes received 33 bytes 452.00 bytes/sec
total size is 11 speedup is 0.05
–exclude Filter specified files
[root@localhost 111]# rm -rf /tmp/111_dest/*
[root@localhost 111]# rsync -av --exclude "*.txt" /root/111/ /tmp/111_dest
sending incremental file list
./
passwd.l -> /etc/passwd
sent 85 bytes received 22 bytes 214.00 bytes/sec
total size is 11 speedup is 0.10
[root@localhost 111]# ls /tmp/111_dest/
passwd.l
-P Display synchronization process, such as speed, more detailed than -v.
[root@localhost 111]# rsync -avP /root/111/ /tmp/111_dest
sending incremental file list
./
1.txt
0 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=5/7)
2.txt
0 100% 0.00kB/s 0:00:00 (xfr#2, to-chk=4/7)
3.txt
0 100% 0.00kB/s 0:00:00 (xfr#3, to-chk=3/7)
a.txt
0 100% 0.00kB/s 0:00:00 (xfr#4, to-chk=2/7)
aaa.txt
0 100% 0.00kB/s 0:00:00 (xfr#5, to-chk=1/7)
passwd.l -> /etc/passwd
sent 388 bytes received 117 bytes 1,010.00 bytes/sec
total size is 11 speedup is 0.02
-u With this option, if files in DEST are new than SRC, they are not synchronized.
[root@localhost 111]# vim /tmp/111_dest/1.txt
jfajsdhafkjdashfkj
[root@localhost 111]# rsync -avPu /root/111/ /tmp/111_dest
sending incremental file list
./
sent 190 bytes received 19 bytes 418.00 bytes/sec
total size is 11 speedup is 0.05
[root@localhost 111]# cat 1.txt
555666
[root@localhost 111]# cat /tmp/111_dest/1.txt
jfajsdhafkjdashfkj
10.31 Rsync” is synchronized through SSH.
Copy file directory to remote server
[root@localhost ~]# rsync -av /etc/passwd root@192.168.1.105:/root/1.txt
root@192.168.1.105's password:
sending incremental file list
passwd
sent 938 bytes received 35 bytes 278.00 bytes/sec
total size is 846 speedup is 0.87
Remote server copies file directory to local machine
[root@localhost ~]# rsync -av root@192.168.1.105:/etc/passwd /tmp/1.txt
root@192.168.1.105's password:
receiving incremental file list
passwd
sent 43 bytes received 937 bytes 217.78 bytes/sec
total size is 846 speedup is 0.86
If the other side is not a 22 port, the port can be specified.
[root@localhost ~]# rsync -av -e "ssh -p 22" test1/ 192.168.133.132:/tmp/test2/
10.32/10.33 Rsync” is synchronized through service.
To edit configuration file /etc/rsyncd.conf
Start service Rsync –daemon
formatrsync -av test1/ 192.168.133.130::module/dir/
- rsyncd.confSample
port=873 //Specified portLog file=/var/log/rsync.log / / specify log filePID file=/var/run/rsyncd.pid / / specify PID fileAddress=192.168.133.130 / / specifies the IP to start the rsyncd service. If your machine has more than one IP, you can specify that one of them starts the rsyncd service. If you do not specify this parameter, the default is to start on all IP.[test] / / module namePath=/rooT/rsync / / specified path for data storageUse chroot=true / / indicates that the directory specified first is chroot to path parameter before transferring files. The reason for this is to achieve additional security, but the disadvantage is the need to use roots privileges.And cannot backup directory files pointing to external symbolic connections. By default, the chroot value is true, and if you have a soft-link file in your data, Amin suggests that you set it to falseMax connections=4 / / specify the maximum number of connectionsThe default is 0, that is, no restrictions.Read only=no / / if it is true, it can not be uploaded to the specified path of the module.List = true // indicates whether the module is listed when the user queries the available module on the server, set to true columnOut, false is hidden.Uid=root / / specifies which user / group identity to be transmitted when transferring files, and nobody has very limited privileges.Gid=rootAuth users=test / / specifies the user name to be used for transmission.SECRets file =/ etc / rsyncd. passwd // specifies a password file that, together with the above parameters, does not use password validation if not specified. Note that the password must be 600. Format: Username: passwordHosts allOw = 192.168.133.132 1.1.1.2.2.2
Be careful
When auth users and secrets files are set up, the client even needs a username password for the server. If you want to carry a password on the command line, you can set a password file.Rsync -avL test@192.168.133.130:: test/test1/ /tmp/test8/ --password-file=/etc/passAmong them, /etc/pass content is a password, and the authority should be changed to 600.
usage
[root@localhost 111]# vim /etc/rsyncd.conf
[root@localhost 111]# rsync --daemon
[root@localhost 111]# ps aux |grep rsync
root 11775 0.0 0.0 114740 556 ? Ss 20:24 0:00 rsync --daemon
root 11777 0.0 0.0 112720 972 pts/0 R+ 20:24 0:00 grep --color=auto rsync
[root@localhost2 ~]# rsync -av /etc/passwd 192.168.1.104::test/aming-02.txt
Specified port
[root@localhost ~]# rsync -av --port 8730 /etc/passwd 192.168.1.104::test/aming-02.txt
List all modules
[root@localhost ~]# rsync 192.168.1.104::
10.34 Linux system log”
/var/log/messages
/etc/logrotate.conf Log cut configuration file
weekly //Cut once a week.Rotate 4 / / keep 4 documentsCreate / / create new log fileDateext / date suffix#compress / / compressionInclude /etc/logrotate.dVar/log/wtmp {MonthlyCreate 0664 root utmpMinsize 1MRotate 1}/var/log/btmP {MissingokMonthlyCreate 0600 root utmpRotate 1}
Reference https://my.oschina.net/u/2000675/blog/908189
dmesgCommand to view hardware information in memory.
dmesg -c Clear log
/var/log/dmesg Logs are not related to dmesg commands.
lastCommand, invoked file /var/log/wtmp, user login information
lastbCommand to view failed users, corresponding files /var/log/btmp
/var/log/secure security log
10.35 screen tool”
To prevent accidental interruption of a task.
nohup command & Throw the script into the background
screenIt’s a virtual terminal.
Installation toolyum install -y screen
screenEnter the virtual terminal directly.
ctrl aComposite key and press D to exit the virtual terminal, but not the end.
[detached from 11987.pts-0.localhost]
screen -ls View virtual terminal list
oot@localhost 111]# screen -ls
There is a screen on:
11987.pts-0.localhost (Detached)
1 Socket in /var/run/screen/S-root.
screen -r id Access to designated terminal
screen -r aming
screen -S aming Custom terminal name
screen -r aming
exit Sign out