世の中のもやもやを「スッキリ」と!!

コンピュータ関係をつぶやきます。世の中の役に立つことを書いていきたいです。

rsyncのシンボリックリンクをコピーするオプションを試してみる。

rsyncシンボリックリンクをコピーするオプションを試してみる。
 
rsync(Ver3.1.1、samba.rsyncソースからビルドしたもの)
 
[root@vbox01 /]# which rsync
/usr/local/bin/rsync
[root@vbox01 /]# rsync --version
rsync  version 3.1.1  protocol version 31
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others.
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, prealloc
 
 
ディレクトリ構成
/ (ルートパーティション)
Ldata2―aaa(bbbへのSymbolic Link)
   ―bbb(実体)
   ―ccc(/data3/dddへのSymbolic Link)
Ldata3―ddd(実体)
   ―destdir(コピー先ディレクトリ
 
このような構成の場合
 
普通のarchiveモードだと
 
[root@vbox01 data3]# rsync -av /data2/aaa /data3/destdir
sending incremental file list
aaa -> bbb
 
sent 53 bytes  received 19 bytes  144.00 bytes/sec
total size is 3  speedup is 0.04
[root@vbox01 data3]# cd destdir/
[root@vbox01 destdir]# ll
合計 0
lrwxrwxrwx 1 root root 3 11月 29 20:40 2015 aaa -> bbb
 
シンボリックリンクデッドリンクとしてコピーされる。
 
[root@vbox01 destdir]# rsync -av --copy-links /data2/aaa /data3/destdir
sending incremental file list
aaa

sent 103 bytes  received 35 bytes  276.00 bytes/sec
total size is 14  speedup is 0.10
[root@vbox01 destdir]# ll
合計 4
-rw-r--r-- 1 root root 14 11月 29 20:40 2015 aaa
[root@vbox01 destdir]# more aaa
bbb file desu
 
実体の方がコピーできている。ファイル名はシンボリックリンクでつけていた名前のaaaとなる。
 
[root@vbox01 destdir]# rsync -av --safe-links /data2/aaa /data3/destdir
sending incremental file list
aaa -> bbb

sent 53 bytes  received 19 bytes  144.00 bytes/sec
total size is 3  speedup is 0.04
[root@vbox01 destdir]# ll
合計 0
lrwxrwxrwx 1 root root 3 11月 29 20:40 2015 aaa -> bbb
 
safe-linksだとシンボリックリンクデッドリンクでコピーされている。
 
[root@vbox01 destdir]# rsync -av --copy-unsafe-links /data2/aaa /data3/destdir
sending incremental file list

sent 46 bytes  received 12 bytes  116.00 bytes/sec
total size is 3  speedup is 0.05
[root@vbox01 destdir]# ll
合計 0
lrwxrwxrwx 1 root root 3 11月 29 20:40 2015 aaa -> bbb
 
--cpy-unsafe-linksだと何もコピーされない。(これは合っている気がする)
 
[root@vbox01 destdir]# rsync -av --keep-dirlinks /data2/aaa /data3/destdir
sending incremental file list

sent 46 bytes  received 12 bytes  116.00 bytes/sec
total size is 3  speedup is 0.05
 
これもあまり意味がないか。