example is probably the best way. But due to lack of bandwidth I only mirror selected directories on remote sites. However, using rysnc with the --delete option doesn't delete missing files (from the source) in the destination directory. Example (very simple) root@cumulus rsync]# ls -laR .: total 16 drwxr-xr-x 4 root root 4096 Sep 17 15:13 . drwxr-x--- 25 root root 4096 Sep 17 15:13 .. drwxr-xr-x 2 root root 4096 Sep 17 15:13 dira drwxr-xr-x 2 root root 4096 Sep 17 15:14 dirb ./dira: total 16 drwxr-xr-x 2 root root 4096 Sep 17 15:13 . drwxr-xr-x 4 root root 4096 Sep 17 15:13 .. -rw-r--r-- 1 root root 16 Sep 17 15:13 tfile.1 -rw-r--r-- 1 root root 16 Sep 17 15:13 tfile.2 ./dirb: total 16 drwxr-xr-x 2 root root 4096 Sep 17 15:14 . drwxr-xr-x 4 root root 4096 Sep 17 15:13 .. -rw-r--r-- 1 root root 16 Sep 17 15:13 tfile.1 -rw-r--r-- 1 root root 16 Sep 17 15:13 tfile.2 root@cumulus rsync]# rm dira/tfile.1 rm: remove regular file `dira/tfile.1'? y [root@cumulus rsync]# echo $RANDOM - $RANDOM >> dira/tfile.2 [root@cumulus rsync]# ls -laR .: total 16 drwxr-xr-x 4 root root 4096 Sep 17 15:13 . drwxr-x--- 25 root root 4096 Sep 17 15:13 .. drwxr-xr-x 2 root root 4096 Sep 17 15:16 dira drwxr-xr-x 2 root root 4096 Sep 17 15:14 dirb ./dira: total 12 drwxr-xr-x 2 root root 4096 Sep 17 15:16 . drwxr-xr-x 4 root root 4096 Sep 17 15:13 .. -rw-r--r-- 1 root root 30 Sep 17 15:16 tfile.2 ./dirb: total 16 drwxr-xr-x 2 root root 4096 Sep 17 15:14 . drwxr-xr-x 4 root root 4096 Sep 17 15:13 .. -rw-r--r-- 1 root root 16 Sep 17 15:13 tfile.1 -rw-r--r-- 1 root root 16 Sep 17 15:13 tfile.2 root@cumulus rsync]# rsync -lptgoDv --delete dira/* dirb tfile.2 sent 124 bytes received 40 bytes 328.00 bytes/sec total size is 30 speedup is 0.18 [root@cumulus rsync]# ls -laR .: total 16 drwxr-xr-x 4 root root 4096 Sep 17 15:13 . drwxr-x--- 25 root root 4096 Sep 17 15:13 .. drwxr-xr-x 2 root root 4096 Sep 17 15:16 dira drwxr-xr-x 2 root root 4096 Sep 17 15:17 dirb ./dira: total 12 drwxr-xr-x 2 root root 4096 Sep 17 15:16 . drwxr-xr-x 4 root root 4096 Sep 17 15:13 .. -rw-r--r-- 1 root root 30 Sep 17 15:16 tfile.2 ./dirb: total 16 drwxr-xr-x 2 root root 4096 Sep 17 15:17 . drwxr-xr-x 4 root root 4096 Sep 17 15:13 .. -rw-r--r-- 1 root root 16 Sep 17 15:13 tfile.1 -rw-r--r-- 1 root root 30 Sep 17 15:16 tfile.2
This is not a bug, but an all-too-common operator error. The '*' wildcard expands into many separate files, so no deletion can occur because no directory was transferred. Simply remove the '*' (leaving the trailing slash) and all will be well.