diff --git a/home/scripts/backup-home.sh b/home/scripts/backup-home.sh new file mode 100644 index 0000000..9214274 --- /dev/null +++ b/home/scripts/backup-home.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +export RESTIC_PASSWORD="gunter.home.2rjus.net" +export RESTIC_REPOSITORY="rest:http://10.69.12.52:8000/gunter.home.2rjus.net" + +notify-send -e -t 3000 "Backup started" "Backup of /home/torjus started" +SECONDS=0 +restic backup /home/torjus \ + --exclude '/home/torjus/.cache' \ + --exclude '/home/torjus/.local/share/Steam' \ + --exclude '/home/torjus/git/nixpkgs' +retval=$? +if [ $retval -ne 0 ]; then + notify-send -u critical "Backup failed" "Backup of /home/torjus failed" + exit 1 +fi +restic forget -d 7 -w 4 -m 6 --prune + +notify-send -e -t 3000 "Backup completed" "Backup of /home/torjus completed in $SECONDS seconds." diff --git a/home/scripts/default.nix b/home/scripts/default.nix index 69edd4e..4f55b66 100644 --- a/home/scripts/default.nix +++ b/home/scripts/default.nix @@ -11,4 +11,8 @@ source = ./randomwp.sh; executable = true; }; + home.file.".local/bin/backup-home" = { + source = ./backup-home.sh; + executable = true; + }; }