0

I'm doing this:

rsync ~/Desktop/files/ /media/myDrive/ -vbrh --progress

for backing up (-b) recursively (-r). I requested also verbose and human readable output, and a progress bar.

Now if I change or move a file from ~/Desktop/files to a subdirectory, it backs up the whole thing again, not just the one modified file.

Can you give me any hint please?

PS:

I've seen many websites, for example [HowToGeek][1] and I'm a bit confused in the flags they use, so I went my own way so far.

2
  • 1
    Honestly, getting rsync to do what you want is an art, not a science. You might want to use av and look into --delete. You definitely want to test with --dry-run until you get it right. For example, the trailing slash on a path is different than without. Also, ensure the target timestamps are valid, especially if the target is a network mount or a different filesystem (like FAT32). May 26, 2020 at 22:36
  • Maybe it is not copying everything. Ask rsync to tell you what it's doing with each file with the -i flag. Since it looks like your doing it onto another filesystem, maybe rsync is just updating the permissions, or the timestamps. It really depends on the filesystem in /media/myDrive. Post the first few lines of the itemized output if you don't understand it. May 26, 2020 at 22:57

3 Answers 3

1

Ok, so i think your problem is with -b option. From man:

   -b, --backup
          With this option, preexisting destination files are renamed as each file is transferred or deleted.  You can control where the backup file goes and what (if  any)  suffix
          gets appended using the --backup-dir and --suffix options.

          Note  that  if  you  don’t specify --backup-dir, (1) the --omit-dir-times option will be implied, and (2) if --delete is also in effect (without --delete-excluded), rsync
          will add a "protect" filter-rule for the backup suffix to the end of all your existing excludes (e.g. -f "P *~").  This will prevent previously backed-up files from being
          deleted.   Note  that if you are supplying your own filter rules, you may need to manually insert your own exclude/protect rule somewhere higher up in the list so that it
          has a high enough priority to be effective (e.g., if your rules specify a trailing inclusion/exclusion of ’*’, the auto-added rule would never be reached).

Whenever you sync your files, it will sync them again, and it will put ~ sufix after the old file name (file~).

I don't know what is your end goal, but if you just want to bakup ~/Desktop/files/ use this:

rsync -avP ~/Desktop/files/ /media/myDrive/

If you want to be exact match (deleting the files that are not in ~/Desktop/files/ anymore {i think that is what you are looking for}):

rsync -avP --delete ~/Desktop/files/ /media/myDrive/

*-P same as --partial --progress

0

I can give you some clue about directory paths that may be confusing. In the below line:

rsync ~/Desktop/files/ /media/myDrive/ -vbrh --progress

it will sync the files inside the path ~/Desktop/files/ to be inside this path /media/myDrive/

If you put the path like the below:

rsync ~/Desktop/files /media/myDrive/ -vbrh --progress

it will sync the root directory itself in the path ~/Desktop/files including the files inside since you are using -r option. meaning that using the above comand you will see "files" directory on the destination path /media/myDrive/ this may justify why it redo the full sync when you change the path.

1
  • Hm.. I forgot about (thanks!) that but it's not the case because I've used exactly the same command...
    – mrnobody
    May 27, 2020 at 9:10
0

I think you normally put flags before the directories, I certainly do, but perhaps both ways possible. Most common for backups just put -a (archive, which is shortcut for all right flags like recursive, keep permissions, time stamps etc), it will be all that you need. For my backups I do

rsync -avp --delete --stats /source/ /destination/

--delete will remove files from destination, which do not exist any more at source

--stats will give you summary at the end of copying

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .