2018-03-27 Linux学習
5367 ワード
10.28 rsyncツールの説明
10.29 rsync共通オプション
10.30 rsyncの一般的なオプション
10.31 Linuxファイル同期ツールrsync
rsync -av /etc/passwd /tmp/1.txt
rsync -av /tmp/1.txt 192.168.188.128:/tmp/2.txt
rsync
rsync [OPTION] ...SRC DEST
rsync [OPTION] ...SRC [user@]host:DEST
rsync [OPTION] ...[user@]host:SRC DEST
rsync [OPTION] ...SRC [user@]host::DEST
rsync [OPTION] ...[user@]host::SRC DEST
[root@aming-01 system]# rsync -av /etc/passwd /tmp/1.txt
sending incremental file list
passwd
sent 1128 bytes received 31 bytes 2318.00 bytes/sec
total size is 1054 speedup is 0.91
10.29 rsync共通オプション
rsync
-a -rtplgoD
-r , cp -r
-v ,
-l
-L ,
-p
-o
-g
-D
-t
--delete DEST SRC
--exclude , --exclude "logs" logs ,
-P , , -v
-u , DEST SRC ,
-z
10.30 rsyncの一般的なオプション
[root@aming-01 ~]# rsync -av /root/ /tmp/rootbak/
sending incremental file list
created directory /tmp/rootbak
./
.bash_history
.bash_logout
.bash_profile
.bashrc
.cshrc
.tcshrc
.viminfo
1.txt
a.txt
anaconda-ks.cfg
bacaa
bacab
bacac
.pki/
.pki/nssdb/
.ssh/
.ssh/authorized_keys
.ssh/known_hosts
awk/
awk/text.txt
grep/
grep/grep.log
grep/inittab
grep/passwd
sed/
sed/test.txt
sed/test.txt.bac
sent 581498 bytes received 438 bytes 1163872.00 bytes/sec
total size is 579989 speedup is 1.00
[root@aming-01 ~]# touch /tmp/rootbak/0011.txt
[root@aming-01 ~]# rsync -av --delete /root/ /tmp/rootbak/
sending incremental file list
./
deleting 0011.txt
sent 528 bytes received 21 bytes 1098.00 bytes/sec
total size is 579989 speedup is 1056.45
[root@aming-01 ~]# rsync -av --exclude "*txt" /root/ /tmp/rootbak
sending incremental file list
created directory /tmp/rootbak
./
.bash_history
.bash_logout
.bash_profile
.bashrc
.cshrc
.tcshrc
.viminfo
anaconda-ks.cfg
bacaa
bacab
bacac
.pki/
.pki/nssdb/
.ssh/
.ssh/authorized_keys
.ssh/known_hosts
awk/
grep/
grep/grep.log
grep/inittab
grep/passwd
sed/
sed/test.txt.bac
sent 329932 bytes received 362 bytes 660588.00 bytes/sec
total size is 328682 speedup is 1.00
[root@aming-01 ~]# rsync -avP --exclude "*txt" /root/ /tmp/rootbak
sending incremental file list
created directory /tmp/rootbak
./
.bash_history
26302 100% 0.00kB/s 0:00:00 (xfer#1, to-check=22/24)
.bash_logout
18 100% 17.58kB/s 0:00:00 (xfer#2, to-check=21/24)
.bash_profile
176 100% 171.88kB/s 0:00:00 (xfer#3, to-check=20/24)
.bashrc
176 100% 171.88kB/s 0:00:00 (xfer#4, to-check=19/24)
.cshrc
100 100% 97.66kB/s 0:00:00 (xfer#5, to-check=18/24)
.tcshrc
129 100% 125.98kB/s 0:00:00 (xfer#6, to-check=17/24)
.viminfo
5673 100% 5.41MB/s 0:00:00 (xfer#7, to-check=16/24)
anaconda-ks.cfg
1420 100% 1.35MB/s 0:00:00 (xfer#8, to-check=15/24)
bacaa
102400 100% 48.83MB/s 0:00:00 (xfer#9, to-check=14/24)
bacab
102400 100% 24.41MB/s 0:00:00 (xfer#10, to-check=13/24)
[root@aming-01 ~]# vim /tmp/rootbak/anaconda-ks.cfg
[root@aming-01 ~]# rsync -avPu --exclude "*txt" /root/ /tmp/rootbak
sending incremental file list
.viminfo
5785 100% 0.00kB/s 0:00:00 (xfer#1, to-check=16/24)
sent 6294 bytes received 37 bytes 12662.00 bytes/sec
total size is 328794 speedup is 51.93
[root@aming-01 ~]# rsync -avPz --exclude "*txt" /root/ /tmp/rootbak
sending incremental file list
created directory /tmp/rootbak
./
.bash_history
26302 100% 0.00kB/s 0:00:00 (xfer#1, to-check=22/24)
.bash_logout
18 100% 17.58kB/s 0:00:00 (xfer#2, to-check=21/24)
.bash_profile
176 100% 171.88kB/s 0:00:00 (xfer#3, to-check=20/24)
.bashrc
176 100% 171.88kB/s 0:00:00 (xfer#4, to-check=19/24)
.cshrc
100 100% 97.66kB/s 0:00:00 (xfer#5, to-check=18/24)
.tcshrc
129 100% 125.98kB/s 0:00:00 (xfer#6, to-check=17/24)
.viminfo
5785 100% 5.52MB/s 0:00:00 (xfer#7, to-check=16/24)
anaconda-ks.cfg
1420 100% 1.35MB/s 0:00:00 (xfer#8, to-check=15/24)
bacaa
102400 100% 19.53MB/s 0:00:00 (xfer#9, to-check=14/24)
10.31 Linuxファイル同期ツールrsync
rsync ssh
rsync -av test1/ 192.168.133.132:/tmp/test2
rsync -avP -e "ssh -p 22" test/ 192.168.133.132:/tmp/test2/
rsync
/etc/rsyncd.conf
rsync --daemon
: rsync -av test1/ 192.168.133.130::module/dir/
[root@aming-01 ~]# rsync -av /etc/passwd 192.168.104.165:/tmp/aming.txt
[email protected]'s password:
sending incremental file list
passwd
sent 1128 bytes received 31 bytes 331.14 bytes/sec
total size is 1054 speedup is 0.91