4

I am doing a remote backup. This are my rsnapshot config.

config_version  1.2
snapshot_root   /data/sbackup/
cmd_cp  /bin/cp
cmd_rm  /bin/rm
cmd_rsync       /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger      /usr/bin/logger
interval        alpha   2
interval        beta    2
interval        gamma   2
interval        delta   1
ssh_args    -p xxxx
verbose         3
loglevel        4
logfile /var/log/rsnapshot/
exclude_file    /data/xxxxx.exclude
rsync_long_args --stats --delete --numeric-ids --relative   --delete-excluded
lockfile        /var/run/rsnapshot.pid
backup  [email protected]:/ xxxxx-server/

I have added this bottom lines in exclude_file

+ /root
+ /backups/mysqldb/latest
+ /etc/automysqlbackup
+ /etc/imscp
+ /etc/postfix
+ /etc/fail2ban
+ /etc/dovecot
+ /etc/apache2
+ /etc/ssh
+ /etc/ssl
+ /etc/php5
+ /etc/cron.d
+ /usr
+ /var/mail
+ /var/www
+ /var/log
- /var/cache
- /boot
- /home
- /opt
- /etc
- /*

But after doing a rsync I am only getting full root & usr directory's. No other mentioned + path files/sub directories are getting downloaded.

I want + directories to be includes and - not to be includes.

What I am doing wrong?.

1
  • Is there a documentation about the plus and minus sign? Is this valid for the latest rsnapshot version ?
    – MaXi32
    Jul 26, 2020 at 3:32

2 Answers 2

3

the syntax is difficult, but not impossible once you get the hang of it, the trick is to realize you must list the directories to match one by one relative to the the root of the rsync/rsnapshot working directory:

say you want to include the /var/log directory and nothing else

+ /var  # we want the var directory
+ /var/log # we want the var/log directory
- /var/* # we dont want anything else in the var directory
- /* # we don't want anything else at all

Hope you see it, first we have a match on /var, then on /var/log, then on /var/* and then on /*.

This would not work

+ /var/log
- /*

because /var/log will not generate a match, oddly enough....

In your example your first

+ /backups/mysqldb/latest

would never create a match.. for the same reason!

1
  • I have changed my decision and marking this better explained as final answer. Apr 21, 2016 at 5:48
0

It seems your exclude pattern /* means that any paths like /etc/something will be excluded unless you explicitly include /etc and then exclude those you don't want with /etc/*.

So add + /etc and - /etc/*, and similarly for /var and /backups and /backups/mysqldb.

By the way, I said earlier you needed 2 files, a separate include_file and exclude_file. You can do this, but in fact if you start each line in the file with an explicit '+ ' or '- ' it overrides the default include or exclude aspect. So you can put all in one file, provided you prefix the lines as you have done.

5
  • Thanks for reply. I tried this solution by making include and exclude file separately but not working. I am still getting /root & /usr dir only. Sep 14, 2015 at 5:42
  • I've added a probable solution.
    – meuh
    Sep 14, 2015 at 11:35
  • So, you are saying that I should add - /etc/apache2 to make it exclude and add only + /etc to copy everything else from /etc ?. Isn't this something I have done before in one file above?. Sep 14, 2015 at 19:23
  • no. you say you want to include /etc/apache2, so it has a +. Keep that entry. I say add - /etc/* (that's a pattern) to exclude any other dirs in /etc you have not explicitly mentioned in the list. You have to remove the - /etc which I hadnt noticed.
    – meuh
    Sep 14, 2015 at 19:29
  • Thank you :) . I have tried adding - /etc/* for excluding all others except the ones I want with + /etc/something and by removing - /etc/* But this didn't worked out. What it did worked is if I add also + /etc explicitly then it started working. So it looks like I have to add both + /etc & - /etc/* along with + /etc/something to include all sub dirs within /etc dir. Thanks for your solution though. I will mark it as accepted answer as this idea leads me to configure file correctly. :) Sep 15, 2015 at 5:14

You must log in to answer this question.

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