-
-
Save izikeros/20679d3c36cedd66d2fdca5526f03964 to your computer and use it in GitHub Desktop.
Restic backup with .gitignore style excludes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TEMPFILE='/tmp/restic_ignores.txt' | |
BACKUPDIR=$HOME | |
# Note: Not sure which way is better, echo nothing into the file, or remove if exists | |
# if [ -f $TEMPFILE ]; then | |
# rm $TEMPFILE | |
# fi | |
# touch $TEMPFILE | |
echo > $TEMPFILE | |
IGNOREFILES=`find $BACKUPDIR -name '.restic_ignore' -print` | |
for IGNOREFILE in $IGNOREFILES | |
do | |
PATTERNS=`cat $IGNOREFILE` | |
for PATTERN in $PATTERNS | |
do | |
printf "%s/%s\n" $(dirname $IGNOREFILE) $PATTERN >> $TEMPFILE | |
done | |
done | |
restic backup $BACKUPDIR --exclude-file=$TEMPFILE --exclude-caches # and any other options here | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment