From 39677bbc585ac877bec370ebfe4ffa9317c07d4f Mon Sep 17 00:00:00 2001 From: Thibaud Gasser Date: Wed, 13 Nov 2019 23:13:08 +0000 Subject: [PATCH] Manage variables via systemd override config (#4) Use systemd override configuration to avoid putting sensitive informations in the service file (and so in the git repository). - add a makefile to install and uinstall the service - add some documentation to README.md See #1 --- .gitignore | 1 + Makefile | 13 +++++++++++++ README.md | 21 +++++++++++++++++++++ borgbackup.service | 7 ++----- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 5dd7d68..de19d2f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ !exclude-list-S551LN.txt !README.md !Makefile +!.gitignore * diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e7a9a6d --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +systemd_path := /etc/systemd/system +install: + cp borgbackup.* $(systemd_path)/ + chmod a+x $(systemd_path)/borgbackup.* + systemctl edit borgbackup.service + systemctl enable borgbackup.timer + systemctl start borgbackup.timer + +uninstall: + systemctl disable borgbackup.timer + rm -rvf $(systemd_path)/borgbackup.service + rm -rvf $(systemd_path)/borgbackup.timer + rm -rvf /etc/systemd/system/borgbackup.service.d diff --git a/README.md b/README.md index 542be43..915f0e2 100644 --- a/README.md +++ b/README.md @@ -1 +1,22 @@ # Backup configuration for S551LN laptop + +## Install + +- run the command `make install` as admin +- in the editor that opens, write the following configuration: + ``` + [Service] + Environment=BORG_REPO=/path/to/borg/repo + Environment=BORG_PASSPHRASE=somEp4$sphrase + Environment=EXCLUDE_LIST=/path/to/exclude/list + ``` + +## Uninstall + +`make uninstall` + +## Run manual backup + +- use `systemctl start borgbackup.service` to run a backup manually +- use `journalctl -u borgbackup.service` to view the logs + diff --git a/borgbackup.service b/borgbackup.service index 006bc14..c2505a0 100644 --- a/borgbackup.service +++ b/borgbackup.service @@ -3,13 +3,10 @@ Description=Borg backup [Service] Type=oneshot -Environment=BORG_REPO=/mnt/data/thibaud/backups/S551LN/S551LN.borg/ Environment=BORG_HOSTNAME_IS_UNIQUE=yes -Environment=BORG_PASSPHRASE=***REMOVED*** -Environment=BORG_KEY_FILE=/home/thibaud/.config/borg/keys/S551LN_borg.2 Nice=19 -ExecStart=/usr/local/bin/borg create --list --stats --filter AME --exclude-from=/mnt/data/thibaud/backups/S551LN/exclude-list-S551LN.txt ::{now} / -ExecStartPost=/usr/local/bin/borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=10 --keep-within 2d --stats :: +ExecStart=/usr/bin/borg create --list --stats --filter AME --exclude-from=${EXCLUDE_LIST} ::{now} / +ExecStartPost=/usr/bin/borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=10 --keep-within 2d --stats :: [Install] WantedBy=multi-user.target