I want to do a Linux system backup with rsync
and my backup strategy exclude everything except what I explicitely want. I am not succeeding in finding the correct filter rules.
I have the file sync_filter
:
+ /etc
+ /home
+ /opt
+ /root
+ /srv
+ /var/backup
+ /var/log
+ /var/mail
+ /var/www
- /*
I think, my intention is clear. I want to include /etc
and so on, I want to include /var/log
and /var/mail
but I do not want to include /var/cache
.
I am not succeeding on the /var
part.
Running rsync -av --filter "merge sync_filter" --delete root@remote:/ .
will skip the /var
part completely.
From the documentation, I understand that, e.g. /var/backup
is skipped, because /var
is excluded by - /*
filter.
I also know that I could include + /var
and exclude, e.g. - /var/cache
but I'd like to succeed with my backup strategy exclude everything except what I explicitely want.
I found a solution right afterwards. The filters have to be:
+ /etc
+ /home
+ /opt
+ /root
+ /srv
+ /var
+ /var/backup
+ /var/log
+ /var/mail
+ /var/www
- /var/*
- /*