Check that the server exists before starting backups
This commit is contained in:
parent
5cd757be19
commit
459e74b01a
|
@ -2,7 +2,8 @@
|
||||||
let
|
let
|
||||||
cfg = config.services.az-restic-client-desktop;
|
cfg = config.services.az-restic-client-desktop;
|
||||||
password_file = config.age.secrets.resticKey.path;
|
password_file = config.age.secrets.resticKey.path;
|
||||||
repository = "rest:http://10.7.89.30:8000";
|
backup_server = "10.7.89.30";
|
||||||
|
repository = "rest:http://${backup_server}:8000";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -44,19 +45,24 @@ in
|
||||||
};
|
};
|
||||||
onFailure = [ "unit-status-telegram@%n.service" ];
|
onFailure = [ "unit-status-telegram@%n.service" ];
|
||||||
script = ''
|
script = ''
|
||||||
${pkgs.restic}/bin/restic \
|
# first make sure we can reach the backup server
|
||||||
--exclude-file=${inputs.self}/modules/misc/restic-client/excludes.txt \
|
if ${pkgs.iputils}/bin/ping -c 1 ${backup_server} >/dev/null; then
|
||||||
--tag home-dir \
|
${pkgs.restic}/bin/restic \
|
||||||
backup /home/${config.az-username}
|
--exclude-file=${inputs.self}/modules/misc/restic-client/excludes.txt \
|
||||||
|
--tag home-dir \
|
||||||
|
backup /home/${config.az-username}
|
||||||
|
|
||||||
${pkgs.restic}/bin/restic \
|
${pkgs.restic}/bin/restic \
|
||||||
forget \
|
forget \
|
||||||
--host ${config.networking.hostName} \
|
--host ${config.networking.hostName} \
|
||||||
--keep-hourly 25 \
|
--keep-hourly 25 \
|
||||||
--keep-daily 7 \
|
--keep-daily 7 \
|
||||||
--keep-weekly 5 \
|
--keep-weekly 5 \
|
||||||
--keep-monthly 12 \
|
--keep-monthly 12 \
|
||||||
--keep-yearly 2 \
|
--keep-yearly 2 \
|
||||||
|
else
|
||||||
|
echo "Backup server unreachable."
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue