I am trying to set up rsync backup for my FreeBSD servers.

I’ve put together an rsync-command that looks like this:

rsync -avzhe ssh --progress --delete --delete-excluded \
--exclude-from=/root/rsync-excludes \
-e ssh / backup@my.backup.box:Backups/location

My /root/rsync-excludes file looks like this:

- *~
+ /root
+ /usr/home
+ /usr/srv
+ /etc
+ /usr/local/etc
+ /var/backups
+ /usr/local/pgsql/backups
- /root/.my.cnf
- /*

But for some reason, it only backs up /etc and /root, leaving out the other files. Can someone explain why?

Solution

As per the answer from Gilles, I figured it out, and my config now looks like this:

- *~
+ /etc
+ /root
+ /usr/
+ /usr/home
+ /usr/local/
+ /usr/local/etc
+ /usr/local/git
+ /usr/local/pgsql/
+ /usr/local/pgsql/backups
- /usr/local/pgsql/*
+ /usr/local/varnish
- /usr/local/*
+ /usr/srv
- /usr/*
+ /var/
+ /var/backups
- /var/*
- /root/.my.cnf
- /*
link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

During a recursive traversal, rsync matches each directory against the rules. When it comes to /usr, the first matching rule is - /*. Therefore /usr is excluded, and rsync doesn't even look at anything below it. Fix: explicitly include /usr, as well as /usr/local, /usr/local/pgsql and /var.

The rsync manual has a more extended discussion under “include/exclude pattern rules” (admittedly not the easiest read).

link|improve this answer
Ah, yes, now I get it, thanks :) – mikl Aug 21 '10 at 19:14
feedback

It looks like you are getting --one-file-system behavior. This may be the default on freebsd.

I also see that your destination is not a root account which should break retaining permissions and ownership.

link|improve this answer
--one-file-system is not the default, I was rather that I had the exclusion rules wrong as Gilles suggested. As for the destination not being root, that is true, but it’s not really an issue for my use. – mikl Aug 21 '10 at 19:34
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.