Dear Dale,
On Friday 2 September 2022, 3.35am -0500, Dale wrote:
> time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video/*
> /mnt/10tb/Video/
What is going on here is due to a subtle interplay of rsync’s syntax and
shell wildcard expansion. You can read about the details of rsync
syntax in its man page, but I’ll illustrate here:
rsync has two ways to specify a source directory.
1. Without a trailing slash: `rsync <options> path1/source path2/dest`.
This syncs path1/source -> path2/dest/source.
2. With a trailing slash: `rsync <options> path1/source/ path2/dest`.
This syncs path1/source -> path2/dest.
Note that the two ways lead to different target directories getting
synced with the source directory. I think the command you are looking
for is therefore
time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video /mnt/10tb
or
time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video/
/mnt/10tb/Video
NOTE: I have not tested these commands, I would advise you to run them
with --dry-run first.
Now, why is your original command not deleting the old subdirectory?
Let me illustrate this with another example. Suppose we have the same
directories as in my first example, path1/source and path2/dest. Now
suppose path1/source contains subdirectories foo and bar. These were
synced with path2/dest, which therefore also contains foo and bar. Now
you rename foo to foo-1 in your source directory. So we have
$ ls path1/source
foo-1
bar
$ ls path2/dest
foo
bar
When you type path1/source/*, it therefore gets expanded to:
path1/source/foo-1 path1/source/bar
That’s two different source directories, rsync will sync each
separately to a subdirectory of the same name (because there is no
trailing slash) under path2/dest:
path1/source/foo-1 -> path2/dest/foo-1
path1/source/bar -> path2/dest/bar
And what about path2/dest/foo? Well, it is not included in these two
syncs, so rsync leaves it untouched. The --delete option only affects
what is under your sources and targets, here foo-1 and bar, not foo.
So, to conclude, what you probably want is to use one of the rsync
commands I listed above, which sync the entire source directory with the
target, and will clean up anything under the target that is not under
the source. Instead, what your old command was doing is to look at
every subdirectory and file of the source one by one, which will miss
anything in the target that does not have a corresponding item in the
source.
I hope this helps,
Sincerely,
Bas
--
Sebastiaan L. Zoutendijk • [email protected]