I've tried removing the -u, adding --force but no change. Basically, if
I remove a directory on the source, how do I get it to remove the same
on the backup/target? I went through the options on the man page and
nothing hit me as a fix. What am I missing?
time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video/* /mnt/10tb/Video/
Dear Dale,
On Friday 2 September 2022, 3.35am -0500, Dale wrote:
time rsync -auv --progress --delete /home/dale/Desktop/Crypt/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
/mnt/10tb/Video/
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 • slzoutendijk@gmail.com
time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video/* /mnt/10tb/Video/
f+++++++++ bar
f..t...... foo
Am Fri, Sep 02, 2022 at 03:35:56AM -0500 schrieb Dale:
time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video/*A little OT, but still related:
/mnt/10tb/Video/
Instead of -v, give -i a try. -v only shows you the path of synced files. In addition to that, -i also shows you *why* a file is synced and what exactly is
synced (the whole file, or only permissions or timestamps or other attributes).
An example:
## create source and destination dir, and a source file
$ mkdir a b
$ touch a/foo
## rsync the -v way
$ rsync -av a/ b/
sending incremental file list
./
foo
## update timestamp of first file, create another file, and rsync with -i
$ touch a/{foo,bar}
$ rsync -ai a/ b/
.d..t...... ./
f+++++++++ barSee what it did there? Rsync tells you that it copied the new file "bar",
f..t...... foo
but "foo" only had its timestamp changed, the same as for the root dir, because we added a file to it.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 303 |
Nodes: | 16 (2 / 14) |
Uptime: | 84:15:02 |
Calls: | 6,808 |
Calls today: | 4 |
Files: | 12,328 |
Messages: | 5,401,327 |