attic icon indicating copy to clipboard operation
attic copied to clipboard

--include switch

Open PiQuer opened this issue 11 years ago • 1 comments

First of all, thank you for this impressive peace of software.

I think the counterpart to the --exclude switch could be useful.

Use case: a huge directory DIR which should be excluded and a configuration file DIR/config which should be archived.

attic create $REPOSITORY $HOME --exclude $HOME/DIR --include $HOME/DIR/config

The only other possibilities would be to keep track of the contents of DIR and exclude everything except config within DIR, which is cumbersome and error prone, or to copy DIR/config to some other place before the backup.

PiQuer avatar Aug 19 '14 10:08 PiQuer

Eventho my own 'config-files' usually only contain one include line, I have implemented this via a small wrapper script. This one is for borg, but should work in attic the same way:

INCLUDEFILE=${SCRIPTDIR}/conf/$CONF.include EXCLUDEFILE=${SCRIPTDIR}/conf/$CONF.exclude [ ! -f $INCLUDEFILE ] && echo "Error loading includefile '$INCLUDEFILE'." && exit 1 [ ! -f $EXCLUDEFILE ] && echo "Error loading excludefile '$EXCLUDEFILE'." && exit 1 # Filter comments from include INCLUDELIST=$(egrep -v '^(#| |$)' $INCLUDEFILE) borg create --stats --progress --verbose \ --exclude-from $EXCLUDEFILE \ $BORG_REPO::$PREFIX-$2-{now:%Y%m%d-%H%M%S} \ $INCLUDELIST || exit 1

The relevant line is 'INCLUDELIST=$(egrep -v '^(#| |$)' $INCLUDEFILE)' which loads the file without comments and just passes this list as a commandline parameter.

dragetd avatar Jul 01 '16 06:07 dragetd