diff --git a/justfile b/justfile index 7915009..a16c2e1 100644 --- a/justfile +++ b/justfile @@ -2,3 +2,12 @@ copy-systemd-services: sudo cp ./systemd/recurring-tasks/*.service /etc/systemd/system && \ sudo cp ./systemd/recurring-tasks/*.timer /etc/systemd/system && \ sudo systemctl daemon-reload + +backup-all: + find ./systemd/recurring-tasks -type f -name "*.service" -exec bash -c 'sudo systemctl restart "$(basename "$1")"' _ {} \; + +status-services: + find ./systemd/recurring-tasks -type f -name "*.service" -exec bash -c 'sudo systemctl status "$(basename "$1")"' _ {} \; + +status-timers: + find ./systemd/recurring-tasks -type f -name "*.timer" -exec bash -c 'sudo systemctl status "$(basename "$1")"' _ {} \; diff --git a/systemd/recurring-tasks/grafana-cold-backup.service b/systemd/recurring-tasks/grafana-cold-backup.service new file mode 100644 index 0000000..9a008c8 --- /dev/null +++ b/systemd/recurring-tasks/grafana-cold-backup.service @@ -0,0 +1,14 @@ +[Unit] +Description=Backup Syncthing - Cold +After=network.target + +[Service] +ExecStart=homeassistant-backup --mode cold --sourceFolder /mnt/usb/grafana/hot --targetFolder /mnt/usb/grafana/cold --backupName grafana +WorkingDirectory=/etc/grafana +Restart=off +User=willem +Environment=PATH=/usr/bin:/usr/local/bin +Environment=NODE_ENV=production + +[Install] +WantedBy=multi-user.target diff --git a/systemd/recurring-tasks/grafana-cold-backup.timer b/systemd/recurring-tasks/grafana-cold-backup.timer new file mode 100644 index 0000000..3a62fa3 --- /dev/null +++ b/systemd/recurring-tasks/grafana-cold-backup.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Run grafana cold backup Service every day + +[Timer] +OnBootSec=1min +OnUnitActiveSec=1day +Persistent=true + +[Install] +WantedBy=timers.target + diff --git a/systemd/recurring-tasks/grafana-hot-backup.service b/systemd/recurring-tasks/grafana-hot-backup.service new file mode 100644 index 0000000..8391d68 --- /dev/null +++ b/systemd/recurring-tasks/grafana-hot-backup.service @@ -0,0 +1,14 @@ +[Unit] +Description=Backup Syncthing - Hot +After=network.target + +[Service] +ExecStart=homeassistant-backup --mode hot --sourceFolder /etc/grafana --targetFolder /mnt/usb/grafana/hot --backupName grafana +WorkingDirectory=/etc/grafana +Restart=off +User=willem +Environment=PATH=/usr/bin:/usr/local/bin +Environment=NODE_ENV=production + +[Install] +WantedBy=multi-user.target diff --git a/systemd/recurring-tasks/grafana-hot-backup.timer b/systemd/recurring-tasks/grafana-hot-backup.timer new file mode 100644 index 0000000..b0708c6 --- /dev/null +++ b/systemd/recurring-tasks/grafana-hot-backup.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Run Grafana hot backup Service every hour + +[Timer] +OnBootSec=1min +OnUnitActiveSec=1hour +Persistent=true + +[Install] +WantedBy=timers.target +