9

My situation is this:

  • I have an external hard drive that holds all of my folders in my /home/ directory (/Documents, /Pictures blah blah all in the root of the external HDD)
  • I have used rsync -r ./dir-on-computer/ ./dir-on-external-drive/ for the last couple months.
    Recently I've noticed that it takes a while when i use it and it seems to not just copy files I've changed but also ones I haven't.

It's probably just my lack of patience, but I also have seen rsync -av be used as well for other people's backups (I know the whole archive and verbose tags, but just wondering what the difference is between -av and -r).

So, overall I would like advice on two things:

  • Better ways of using rsync, to make sure it is incremental
  • (another problem) I would like to rsync the files in my Music directory without rsyncing the subdirectories in the Music directory (/Music/other-stuff)

I know I am being pretty lazy by asking this question instead of ploughing google for info, but I would appreciate it if you could give any informaton for my situation.

2
  • There are better options than rsync out there, and rsync isn't natively incremental. I've been using Borg Backup for a few months. It's young, and I've had problems with it leaving stray locks behind, but I'm staying with it for now. I expect it will improve. Jun 23, 2017 at 17:46
  • see the --whole-file option on the man page. Note particularly that --whole-file is applied by default when both the source and destination are local paths, rather than using rsync over the network, where the delta transfer algorithm is used. Jun 23, 2017 at 17:48

2 Answers 2

5

Quick solution, use: First make a dry run ('n') to make sure if rsync is doing right

 rsync -anPv Documents/Pictures/ /media/HDD/Pictures/

Then sync the folders

 rsync -aPv Documents/Pictures/ /media/HDD/Pictures/

If you want to skip some folders:

rsync -aPv --exclude Documents/Pictures/UNWANTED Documents/Pictures/ /media/HDD/Pictures/

This is a good place to check-out more details http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/?utm_source=feedburner

3
  • 1
    The first and second example commands are identical. Not expected so, right? Jan 4, 2020 at 2:16
  • 1
    No, if you look closely the first has the -n switch witch the second one hasn't this is to perform a dry run as the author points out.
    – kl0z
    Dec 27, 2020 at 11:26
  • @kl0z Yes you are right Dec 28, 2020 at 14:47
1

Why do you copy all files again and again. From rsync man page you can read:

        -I, --ignore-times
              Normally rsync will skip any files that are already the same size and have the same modification timestamp.  This option turns off this "quick check" behavior, causing all files to be updated.

And a is set of few other switches along with t:

        -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
        -t, --times                 preserve modification times

So, as far as I understand it, you are copying files and you give them current timestamp (current as for time of backup) and next time when you perform backup rsync assumes that file is different. I would advice to use -a switch as it also sets permissions and ownership of files.

As for second question I would consider using --exclude=PATTERN switch.

2
  • I've been an idiot. So, you suggest to use the -a tag instead of the -r tag? (using the -I tag too?)
    – Jaimin
    Jun 23, 2017 at 17:16
  • @62-6f-62: I'm not by computer right now. -l (small L letter) is included in -a switch (if I remember correctly) and is used to copy symbolic links. If you are referring to --ignore-times then I suggest to use -a only. It should keep timestamps correctly (assuming that file system on external drive can handle it).
    – Kalavan
    Jun 23, 2017 at 17:33

You must log in to answer this question.

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