1 |
Sebastiaan L. Zoutendijk wrote: |
2 |
> Dear Dale, |
3 |
> |
4 |
> On Friday 2 September 2022, 3.35am -0500, Dale wrote: |
5 |
> |
6 |
>> time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video/* |
7 |
>> /mnt/10tb/Video/ |
8 |
> What is going on here is due to a subtle interplay of rsync’s syntax and |
9 |
> shell wildcard expansion. You can read about the details of rsync |
10 |
> syntax in its man page, but I’ll illustrate here: |
11 |
> |
12 |
> rsync has two ways to specify a source directory. |
13 |
> |
14 |
> 1. Without a trailing slash: `rsync <options> path1/source path2/dest`. |
15 |
> This syncs path1/source -> path2/dest/source. |
16 |
> |
17 |
> 2. With a trailing slash: `rsync <options> path1/source/ path2/dest`. |
18 |
> This syncs path1/source -> path2/dest. |
19 |
> |
20 |
> Note that the two ways lead to different target directories getting |
21 |
> synced with the source directory. I think the command you are looking |
22 |
> for is therefore |
23 |
> |
24 |
> time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video /mnt/10tb |
25 |
> |
26 |
> or |
27 |
> |
28 |
> time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Video/ |
29 |
> /mnt/10tb/Video |
30 |
> |
31 |
> NOTE: I have not tested these commands, I would advise you to run them |
32 |
> with --dry-run first. |
33 |
> |
34 |
> Now, why is your original command not deleting the old subdirectory? |
35 |
> Let me illustrate this with another example. Suppose we have the same |
36 |
> directories as in my first example, path1/source and path2/dest. Now |
37 |
> suppose path1/source contains subdirectories foo and bar. These were |
38 |
> synced with path2/dest, which therefore also contains foo and bar. Now |
39 |
> you rename foo to foo-1 in your source directory. So we have |
40 |
> |
41 |
> $ ls path1/source |
42 |
> foo-1 |
43 |
> bar |
44 |
> |
45 |
> $ ls path2/dest |
46 |
> foo |
47 |
> bar |
48 |
> |
49 |
> When you type path1/source/*, it therefore gets expanded to: |
50 |
> path1/source/foo-1 path1/source/bar |
51 |
> |
52 |
> That’s two different source directories, rsync will sync each |
53 |
> separately to a subdirectory of the same name (because there is no |
54 |
> trailing slash) under path2/dest: |
55 |
> |
56 |
> path1/source/foo-1 -> path2/dest/foo-1 |
57 |
> path1/source/bar -> path2/dest/bar |
58 |
> |
59 |
> And what about path2/dest/foo? Well, it is not included in these two |
60 |
> syncs, so rsync leaves it untouched. The --delete option only affects |
61 |
> what is under your sources and targets, here foo-1 and bar, not foo. |
62 |
> |
63 |
> So, to conclude, what you probably want is to use one of the rsync |
64 |
> commands I listed above, which sync the entire source directory with the |
65 |
> target, and will clean up anything under the target that is not under |
66 |
> the source. Instead, what your old command was doing is to look at |
67 |
> every subdirectory and file of the source one by one, which will miss |
68 |
> anything in the target that does not have a corresponding item in the |
69 |
> source. |
70 |
> |
71 |
> I hope this helps, |
72 |
> |
73 |
> Sincerely, |
74 |
> |
75 |
> Bas |
76 |
> |
77 |
> |
78 |
> -- |
79 |
> Sebastiaan L. Zoutendijk • slzoutendijk@×××××.com |
80 |
> |
81 |
> |
82 |
|
83 |
|
84 |
Replying here for Ramon too. |
85 |
|
86 |
When I read Ramon's reply earlier, I remembered that the trailing slash |
87 |
and even the "*" I had in there was likely the cause. I recalled |
88 |
reading how that affects all sorts of things when it comes to copying or |
89 |
moving files ages ago. Thing is, it can get a little complicated. |
90 |
However, once one understands how it works, it kinda makes sense that it |
91 |
works that way. :-D Reading both replies helped jog my memory, which |
92 |
is awful nowadays. :-( |
93 |
|
94 |
So for anyone running up on either of these two great explanations, this |
95 |
is what worked for me. |
96 |
|
97 |
|
98 |
time rsync -auv --progress --delete /home/dale/Desktop/Crypt/Videos |
99 |
/mnt/10tb/ |
100 |
|
101 |
|
102 |
When I ran that, it deleted directories that I had changed the names of |
103 |
or something that were no longer on the source but were still on the |
104 |
target. Basically, for the source I removed the "/*" part and the |
105 |
directory on the target. It freed up quite a bit of space too. That |
106 |
works like I expect it to. |
107 |
|
108 |
Now to go fix the other backup script thingys so they work right. No |
109 |
telling how many of those have deleted directories on them. |
110 |
|
111 |
Thanks much to both. Reminded me of something I'd forgot about. |
112 |
Something we should all remember but sadly, I didn't. :/ |
113 |
|
114 |
Dale |
115 |
|
116 |
:-) :-) |
117 |
|
118 |
P. S. I ordered a 14TB drive. It's a Seagate EXOS X18 14TB |
119 |
ST14000NM000J which I think doesn't have that pin 3 problem. I got it |
120 |
for $150. My plan, replace one of the 8TB drives in my system, then I |
121 |
can put the 8TB drive in whatever storage solution I build. I also |
122 |
measured my current fire safe, I can't find a case that will fit in |
123 |
there that holds enough drives. I'd have to go with a ITX, Raspberry Pi |
124 |
type thing to get it to fit in the safe and even that could be a tight |
125 |
squeeze. I could put it in a out building but I really hate to put |
126 |
anything electronic in it. Stuff grows in there, rust too. Air is |
127 |
pretty stale and just not good for anything electronic. This fast |
128 |
internet is causing some problems but I'm still loving it. :-D |