add bin/backup-restic

This commit is contained in:
2024-03-28 21:52:39 +00:00
parent 651f86fd46
commit 57d6727306

45
bin/backup-restic Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
# DRY="-n "
DRY=
CONFIG_ROOT="$HOME/.config/restic"
usage() {
echo "$0 <backup>"
echo
echo "Known profiles:"
echo
ls -1 $CONFIG_ROOT
exit 1
}
if [ ! -d $CONFIG_ROOT ] ; then
echo "$CONFIG_ROOT hasn't been created; you need to create a profile for the backup you want to run."
exit 1
fi
if [ $# -lt 1 ] ; then
usage
fi
PROFILE=$1
shift
PROFILE_ROOT=$CONFIG_ROOT/$PROFILE
export RESTIC_PASSWORD_COMMAND="pass restic/$PROFILE/$HOSTNAME"
CMDLINE="restic backup --one-file-system --exclude-caches $DRY"
EXCLUDE_FILE=$PROFILE_ROOT/excludes.txt
if [ -r $EXCLUDE_FILE ] ; then
CMDLINE="$CMDLINE --exclude-file $EXCLUDE_FILE"
fi
REPO=$PROFILE_ROOT/repo.txt
SOURCES=$PROFILE_ROOT/sources.txt
CMDLINE="$CMDLINE -r $(cat $REPO) $(cat $SOURCES)"
# echo "Backup:"
# echo -e "\tPassword command: $RESTIC_PASSWORD_COMMAND"
# echo -e "\tCommand: $CMDLINE"
$CMDLINE