Using rsync for backing up the stuff on an external HDD

backuprsyncterminal

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.

Best Answer

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.

Related Question