Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--include switch #104

Open
PiQuer opened this issue Aug 19, 2014 · 1 comment
Open

--include switch #104

PiQuer opened this issue Aug 19, 2014 · 1 comment

Comments

@PiQuer
Copy link

PiQuer commented Aug 19, 2014

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.

@dragetd
Copy link

dragetd commented Jul 1, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants