More logging for backup-home
This commit is contained in:
parent
5f013e9a5e
commit
e9fe2227f3
@ -3,6 +3,7 @@ let
|
|||||||
# Backup home script
|
# Backup home script
|
||||||
backup-home = pkgs.writeShellScriptBin "backup-home.sh"
|
backup-home = pkgs.writeShellScriptBin "backup-home.sh"
|
||||||
''
|
''
|
||||||
|
echo "========== BACKUP HOME STARTING =========="
|
||||||
export RESTIC_PASSWORD="gunter.home.2rjus.net"
|
export RESTIC_PASSWORD="gunter.home.2rjus.net"
|
||||||
export RESTIC_REPOSITORY="rest:http://10.69.12.52:8000/gunter.home.2rjus.net"
|
export RESTIC_REPOSITORY="rest:http://10.69.12.52:8000/gunter.home.2rjus.net"
|
||||||
GOTIFY_TOKEN=$(<"$XDG_RUNTIME_DIR/gotify_backup_home.txt")
|
GOTIFY_TOKEN=$(<"$XDG_RUNTIME_DIR/gotify_backup_home.txt")
|
||||||
@ -11,8 +12,6 @@ let
|
|||||||
${pkgs.libnotify}/bin/notify-send -u critical "Backup issue" "No Gotify token found"
|
${pkgs.libnotify}/bin/notify-send -u critical "Backup issue" "No Gotify token found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "GOTIFY_TOKEN=$GOTIFY_TOKEN"
|
|
||||||
|
|
||||||
# Send start notification
|
# Send start notification
|
||||||
${pkgs.libnotify}/bin/notify-send -e -t 3000 "Backup started" "Backup of /home/torjus started"
|
${pkgs.libnotify}/bin/notify-send -e -t 3000 "Backup started" "Backup of /home/torjus started"
|
||||||
retval=$?
|
retval=$?
|
||||||
@ -21,6 +20,7 @@ let
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Do the backup
|
# Do the backup
|
||||||
|
echo "========== BACKUP TASK STARTING =========="
|
||||||
SECONDS=0
|
SECONDS=0
|
||||||
${pkgs.restic}/bin/restic backup /home/torjus \
|
${pkgs.restic}/bin/restic backup /home/torjus \
|
||||||
--exclude '/home/torjus/.cache' \
|
--exclude '/home/torjus/.cache' \
|
||||||
@ -38,11 +38,14 @@ let
|
|||||||
-F "message=Please check status of backup-home service"
|
-F "message=Please check status of backup-home service"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo "========== BACKUP TASK COMPLETE =========="
|
||||||
|
|
||||||
# Remove old snapshots and prune
|
# Remove old snapshots and prune
|
||||||
|
echo "========== PRUNE TASK STARTING =========="
|
||||||
${pkgs.restic}/bin/restic forget -d 7 -w 4 -m 6 --keep-within 1d --prune
|
${pkgs.restic}/bin/restic forget -d 7 -w 4 -m 6 --keep-within 1d --prune
|
||||||
|
echo "========== PRUNE TASK COMPLETE =========="
|
||||||
# Gather statistics
|
# Gather statistics
|
||||||
|
echo "========== STATS TASK STARTING =========="
|
||||||
stats=$(${pkgs.restic}/bin/restic stats --json)
|
stats=$(${pkgs.restic}/bin/restic stats --json)
|
||||||
stats_raw=$(${pkgs.restic}/bin/restic stats --mode=raw-data --json)
|
stats_raw=$(${pkgs.restic}/bin/restic stats --mode=raw-data --json)
|
||||||
|
|
||||||
@ -54,6 +57,7 @@ let
|
|||||||
| ${pkgs.coreutils}/bin/numfmt --to=iec)
|
| ${pkgs.coreutils}/bin/numfmt --to=iec)
|
||||||
total_snapshots=$(${pkgs.jq}/bin/jq -r '.snapshots_count' <<< $stats)
|
total_snapshots=$(${pkgs.jq}/bin/jq -r '.snapshots_count' <<< $stats)
|
||||||
message="$total_files files\n$total_snapshots snapshots\n$raw_size ($total_size)"
|
message="$total_files files\n$total_snapshots snapshots\n$raw_size ($total_size)"
|
||||||
|
echo "========== STATS TASK COMPLETE =========="
|
||||||
|
|
||||||
# Send completion notification
|
# Send completion notification
|
||||||
${pkgs.libnotify}/bin/notify-send -i checkmark -e -t 10000 \
|
${pkgs.libnotify}/bin/notify-send -i checkmark -e -t 10000 \
|
||||||
@ -63,6 +67,7 @@ let
|
|||||||
echo "Failed to send notification"
|
echo "Failed to send notification"
|
||||||
exit $retval
|
exit $retval
|
||||||
fi
|
fi
|
||||||
|
echo "========== BACKUP HOME COMPLETE =========="
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user