From b7b68ba57a3aca7ae75cbd30df02dc98f3bfec07 Mon Sep 17 00:00:00 2001 From: Quentin Duchemin Date: Mon, 25 Mar 2019 23:01:34 +0100 Subject: [PATCH] Add systemd unit for backup --- .config/systemd/backup.service.laptop | 6 ++++++ .config/systemd/backup.timer.laptop | 9 +++++++++ .config/systemd/dest | 1 + .config/systemd/notify-backup-failure.service | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 .config/systemd/backup.service.laptop create mode 100644 .config/systemd/backup.timer.laptop create mode 100644 .config/systemd/dest create mode 100644 .config/systemd/notify-backup-failure.service diff --git a/.config/systemd/backup.service.laptop b/.config/systemd/backup.service.laptop new file mode 100644 index 0000000..4dc3ef0 --- /dev/null +++ b/.config/systemd/backup.service.laptop @@ -0,0 +1,6 @@ +[Unit] +Description=Backup OVH +OnFailure=notify-backup-failure +[Service] +Type=oneshot +ExecStart=/home/.config/backup/rsync/rsync_snapshot.sh 51.75.250.228 diff --git a/.config/systemd/backup.timer.laptop b/.config/systemd/backup.timer.laptop new file mode 100644 index 0000000..16f90f7 --- /dev/null +++ b/.config/systemd/backup.timer.laptop @@ -0,0 +1,9 @@ +[Unit] +Description=Backup OVH weekly + +[Timer] +OnCalendar=weekly +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/.config/systemd/dest b/.config/systemd/dest new file mode 100644 index 0000000..77841b7 --- /dev/null +++ b/.config/systemd/dest @@ -0,0 +1 @@ +/etc/systemd/system diff --git a/.config/systemd/notify-backup-failure.service b/.config/systemd/notify-backup-failure.service new file mode 100644 index 0000000..8ae6bf9 --- /dev/null +++ b/.config/systemd/notify-backup-failure.service @@ -0,0 +1,6 @@ +[Unit] +Description=Send mail on backup failure + +[Service] +Type=oneshot +ExecStart=/usr/bin/bash -c '{ echo -e "Subject: Backup failed\n\nMachine info :\n" ; hostnamectl ; echo -e "\n\nLogs:\n\n" ; journalctl -n 20 -u backup.service; } | sendmail -F "Quentin Duchemin" -f "desktop@chosty.fr" quentin.duchemin@hds.utc.fr'