Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
- /*
share|improve this question
    
Do you think you can restore full system using rsync. –  BigSack Aug 18 '13 at 13:20

2 Answers 2

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).

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

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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