Bug 1791 - using --delete with single directory mirroring doesn't delete files
using --delete with single directory mirroring doesn't delete files
Status: CLOSED INVALID
Product: rsync
Classification: Unclassified
Component: core
2.5.7
x86 Linux
: P3 trivial
: ---
Assigned To: Wayne Davison
Rsync QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-09-17 13:27 UTC by donavan nelson
Modified: 2005-04-01 11:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description donavan nelson 2004-09-17 13:27:53 UTC
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
Comment 1 Wayne Davison 2004-09-17 15:21:41 UTC
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.