add bin/backup-restic
This commit is contained in:
45
bin/backup-restic
Executable file
45
bin/backup-restic
Executable 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
|
||||||
Reference in New Issue
Block a user