splasher
Posts: 4
Joined: Tue Jul 02, 2019 1:49 am

rsync deleting and recopying files - why?

Tue Sep 28, 2021 5:53 pm

Running RPi4 with Buster with two external 500GB USB drives.
My issue is about this rsync command.
sudo rsync -vru --delete /media/USBDRIVE/ /media/pi/MyBookPi/

On USBDRIVE at the root level, there are two folders with several folders and files under them. (This maybe important later.)

I ran the above command three days ago to copy all of the files on USBDRIVE to MyBookPi. After it completed, I added a file to USBDRIVE to test the command to make sure that it only copied the new file since nothing else had changed. That was successful. Next I added a file to MyBookPi, ran the command again and it only deleted the new file, once again, successfully.

So yesterday, I added a new file to one of the sub-sub-folders on USBDRIVE. I then ran the command this morning. It then proceeded to delete all of the files and folders under the root level folder including the root level folder under which that the file was added.

Here is the output of running the command today:
===============================================
pi@RPi4-dlnafile:~ $ sudo rsync -vru --delete /media/USBDRIVE/ /media/pi/MyBookPi/
sending incremental file list
deleting MicroSD_Images/Pi4/RPi4-dlnafile-32GB-PNY-9293-L-1-msd.img
deleting MicroSD_Images/Pi4/RPi4-Baseline-32GB-PNY-9293-L-2-msd.img
deleting MicroSD_Images/Pi4/
deleting MicroSD_Images/Pi3/RPi3-MMR_Static9697-4.23.4_msd-D-4.img
deleting MicroSD_Images/Pi3/RPi3-MMR_Static9697-4.23.4_msd-D-3.img
deleting MicroSD_Images/Pi3/RPi3-File_DLNA-PNY-9091-msd-H-6.img
deleting MicroSD_Images/Pi3/RPi3-DCC-Test-Track-4.23.8-Q-2-SD32.img
deleting MicroSD_Images/Pi3/
deleting MicroSD_Images/
MicroSD_mages/
MicroSD_mages/Pi3/
MicroSD_mages/Pi3/RPi3-DCC-Test-Track-4.23.8-Q-2-SD32.img
MicroSD_mages/Pi3/RPi3-File_DLNA-PNY-9091-msd-H-6.img
MicroSD_mages/Pi3/RPi3-MMR_Static9697-4.23.4_msd-D-3.img
MicroSD_mages/Pi3/RPi3-MMR_Static9697-4.23.4_msd-D-4.img
MicroSD_mages/Pi3/RPi3-PNY-7071-msd-H-1.img <=========== This was the only new file that should have been copied.
MicroSD_mages/Pi4/
MicroSD_mages/Pi4/RPi4-Baseline-32GB-PNY-9293-L-2-msd.img
MicroSD_mages/Pi4/RPi4-dlnafile-32GB-PNY-9293-L-1-msd.img

sent 159,505,866,365 bytes received 651 bytes 22,316,315.78 bytes/sec
total size is 161,210,851,162 speedup is 1.01
pi@RPi4-dlnafile:~ $
===============================================

So, the question is, why were the unchanged files deleted and then recopied along with the new file. I expected that only one file would be copied, not the whole folder.

Am I using the options wrong to only copy new files, overwrite changed files and delete the removed file keeping the destination a virtual copy of the source harddrive?
Thanks in advance.
Using both RPi3 & 4's for model railroading, NAS file sharing and miniDLNA.
-splasher

sparkie777
Posts: 281
Joined: Tue Nov 27, 2012 4:37 am

Re: rsync deleting and recopying files - why?

Tue Sep 28, 2021 6:35 pm

something weird happened to the name of 'MicroSD_Images'. It turns to be 'MicroSD_mages' now?! You accidentally renamed it before rsyncing.

splasher
Posts: 4
Joined: Tue Jul 02, 2019 1:49 am

Re: rsync deleting and recopying files - why?

Tue Sep 28, 2021 7:55 pm

sparkie777 wrote:
Tue Sep 28, 2021 6:35 pm
something weird happened to the name of 'MicroSD_Images'. It turns to be 'MicroSD_mages' now?! You accidentally renamed it before rsyncing.
BINGO. Good eye, I'm not sure I would have ever noticed it since I was just sure it was in my rsync setup. Not sure what I did to cause it, but that was the issue.
I fixed the folder names and the command works as expected.
Thanks a bunch.
Using both RPi3 & 4's for model railroading, NAS file sharing and miniDLNA.
-splasher

Return to “General discussion”