Fix backup-home service
This commit is contained in:
parent
e2f45ccc42
commit
89362838dc
@ -1,19 +0,0 @@
|
||||
#!/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."
|
@ -1,4 +1,4 @@
|
||||
{ config, ... }: {
|
||||
{ pkgs, config, ... }: {
|
||||
home.file.".local/bin/hl-no-opacity" = {
|
||||
source = ./hl-no-opacity.sh;
|
||||
executable = true;
|
||||
@ -11,8 +11,4 @@
|
||||
source = ./randomwp.sh;
|
||||
executable = true;
|
||||
};
|
||||
home.file.".local/bin/backup-home" = {
|
||||
source = ./backup-home.sh;
|
||||
executable = true;
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,39 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
# Backup home script
|
||||
backup-home = pkgs.writeShellScriptBin "backup-home.sh"
|
||||
''
|
||||
export RESTIC_PASSWORD="gunter.home.2rjus.net"
|
||||
export RESTIC_REPOSITORY="rest:http://10.69.12.52:8000/gunter.home.2rjus.net"
|
||||
|
||||
${pkgs.libnotify}/bin/notify-send -e -t 3000 "Backup started" "Backup of /home/torjus started"
|
||||
retval=$?
|
||||
if [ $retval -ne 0 ]; then
|
||||
echo "Failed to send notification"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SECONDS=0
|
||||
${pkgs.restic}/bin/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
|
||||
${pkgs.restic}/bin/restic forget -d 7 -w 4 -m 6 --prune
|
||||
|
||||
${pkgs.libnotify}/bin/notify-send -e -t 3000 "Backup completed" "Backup of /home/torjus completed in $SECONDS seconds."
|
||||
retval=$?
|
||||
if [ $retval -ne 0 ]; then
|
||||
echo "Failed to send notification"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
in
|
||||
{
|
||||
systemd.user.services.backup-home = {
|
||||
Unit = {
|
||||
Description = "Backup home directory";
|
||||
@ -6,7 +41,7 @@
|
||||
};
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "/home/torjus/.local/bin/backup-home";
|
||||
ExecStart = "${backup-home}/bin/backup-home.sh";
|
||||
};
|
||||
};
|
||||
systemd.user.timers.backup-home = {
|
||||
@ -15,7 +50,7 @@
|
||||
After = [ "network.target" ];
|
||||
};
|
||||
Timer = {
|
||||
OnCalendar = "*-*-* 00:00:00";
|
||||
OnCalendar = "*-*-* 0,6,12,18:00:00";
|
||||
Persistent = true;
|
||||
};
|
||||
Install = {
|
||||
|
Loading…
Reference in New Issue
Block a user