Last active
March 31, 2021 07:52
-
-
Save zerodahero/1d6602a9c33d3762d8569e6d3988495a to your computer and use it in GitHub Desktop.
Restic backup with .gitignore style excludes
This file contains 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