rsync
não criaria links simbólicos, mas pode criar links físicos para você:
$ ls -lR test-source
total 4
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 a
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 b
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 c
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 d
drwxr-xr-x 2 kk wheel 512 Oct 22 18:54 dir
test-source/dir:
total 0
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 e
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 f
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 g
-rw-r--r-- 1 kk wheel 0 Oct 22 18:54 h
Use o sinalizador --link-dest
:
$ rsync -av --link-dest="$PWD/test-source" test-source/ test-destination/
sending incremental file list
created directory test-destination
sent 191 bytes received 52 bytes 486.00 bytes/sec
total size is 0 speedup is 0.00
Os arquivos de destino agora são vinculados ao diretório de origem (consulte 2
na segunda coluna da ls -l
output):
$ ls -lR test-destination
total 4
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 a
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 b
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 c
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 d
drwxr-xr-x 2 kk wheel 512 Oct 22 18:54 dir
test-destination/dir:
total 0
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 e
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 f
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 g
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 h
A contagem de links também aumentou nos arquivos no diretório de origem (obviamente):
$ ls -lR test-source
total 4
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 a
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 b
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 c
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 d
drwxr-xr-x 2 kk wheel 512 Oct 22 18:54 dir
test-source/dir:
total 0
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 e
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 f
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 g
-rw-r--r-- 2 kk wheel 0 Oct 22 18:54 h
Para remover arquivos no diretório de destino que não existem no diretório de origem, use o sinalizador --delete
:
$ touch test-destination/delete_me
$ rsync -av --delete --link-dest="$PWD/test-source" test-source/ test-destination/
sending incremental file list
deleting delete_me
./
sent 194 bytes received 29 bytes 446.00 bytes/sec
total size is 0 speedup is 0.00