Flexbackup: Read per-directory exclude expressions from files

Today I wrote a patch to Flexbackup 1.2.1 which allows you to define exclude expressions on a per-directory-base (like svn:ignore, cvs_ignore or tar's --exclude-from). Apply this patch and add the following line to your flexbackup.conf:

$exclude_expr_filename = '.flexbackup_exclude';

This activates an additional routine in the file_list_cmd() method. As soon as the 'find' command has enough parameters to iterate through all directory it is used to retrieve a list of '.flexbackup_exclude' files. Each file is read line by line and a regular expression will build and appended to the directory's name, e.g:

$ cat dummy/.flexbackup_exclude
.*\.tmp$
a_very_big_file\.iso

Will result in the expression:

dummy\/((.*\.tmp$)|(a_very_big_file\.iso))

All files matching this expression will be ignored. This is done by piping find's output through xargs and perl:

find . [conditions...] -print0 | xargs -0 perl -e 'foreach (@ARGV) { print "$_" if ! /dummy\/((.*\.tmp$)|(a_very_big_file\.iso))/ and 1'

If more than one .flexbackup_exclude-file is found more conditions are prepended to the 'and 1'-dummy-condition. Because every condition is tested (and ignored if compilation failed) it should not be possible to break the backup using these files.

Download: flexbackup-exclude-expressions.patch

PS: Perl sucks ;)

Add new comment