Initial import of the script
This commit is contained in:
commit
0da287d5e5
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# restic-cron - Runs a Restic backup on the homedir
|
||||||
|
#
|
||||||
|
# by Paul van Tilburg <paul@luon.net>
|
||||||
|
|
||||||
|
# Nofication function
|
||||||
|
notify() {
|
||||||
|
notify-send -i deja-dup "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if a --verbose argument is passed, otherwise use quiet
|
||||||
|
RESTIC_QUIET="--quiet"
|
||||||
|
if [ "$1" = "--verbose" ]; then
|
||||||
|
RESTIC_QUIET=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Allow for connecting to X11 and the SSH agent
|
||||||
|
eval $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS
|
||||||
|
export DISPLAY=:0
|
||||||
|
export SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
|
||||||
|
export SSH_AGENT_PID=$(pidof ssh-agent)
|
||||||
|
export XAUTHORITY=/run/user/1000/gdm/Xauthority
|
||||||
|
|
||||||
|
# Restic settings
|
||||||
|
export RESTIC_BACKUP_OPTIONS="--exclude-file=$HOME/.config/restic/exclude"
|
||||||
|
export RESTIC_REPOSITORY="sftp://void//media/Backup/entropy"
|
||||||
|
|
||||||
|
# Start the backup by asking for the passphrase
|
||||||
|
notify "Starting backup…"
|
||||||
|
sleep 3
|
||||||
|
export RESTIC_PASSWORD=$(zenity --title="Restic backup passphrase" --password)
|
||||||
|
|
||||||
|
if [ -z "$RESTIC_PASSWORD" ]; then
|
||||||
|
notify "Backup aborted due to empty passphrase or cancellation!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create a new backup
|
||||||
|
restic $RESTIC_QUIET backup $HOME $RESTIC_BACKUP_OPTIONS
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
notify "Unable to finish the backup!"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify the backup
|
||||||
|
restic $RESTIC_QUIET check
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
notify "Repository check of the backup failed!"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
notify "Backup finished!"
|
Loading…
Reference in New Issue