From 49c4f483fd4232f699932ec91a1e8864973ee9f2 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 4 Jul 2016 09:19:34 -0700 Subject: [PATCH] Sample files for triggering borgmatic from a systemd timer. --- NEWS | 1 + README.md | 29 +++++++++++++++++++---- sample/{borgmatic.cron => cron/borgmatic} | 0 sample/systemd/borgmatic.service | 6 +++++ sample/systemd/borgmatic.timer | 8 +++++++ 5 files changed, 40 insertions(+), 4 deletions(-) rename sample/{borgmatic.cron => cron/borgmatic} (100%) create mode 100644 sample/systemd/borgmatic.service create mode 100644 sample/systemd/borgmatic.timer diff --git a/NEWS b/NEWS index 724a7c7..3dc98c5 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 1.0.3-dev * #18: Fix for README mention of sample files not included in package. + * #22: Sample files for triggering borgmatic from a systemd timer. * Added logo. 1.0.3 diff --git a/README.md b/README.md index 00c2b97..4d7f18e 100644 --- a/README.md +++ b/README.md @@ -119,12 +119,33 @@ If you'd like to see the available command-line arguments, view the help: ## Autopilot If you want to run borgmatic automatically, say once a day, the you can -configure a job runner like cron to invoke it periodically. Download the -[sample cron -file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/borgmatic.cron). +configure a job runner to invoke it periodically. + +### cron + +If you're using cron, download the [sample cron +file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/cron/borgmatic). Then, from the directory where you downloaded it: - sudo cp borgmatic.cron /etc/cron.d/borgmatic + sudo mv borgmatic /etc/cron.d/borgmatic + +You can modify the cron file if you'd like to run borgmatic more or less frequently. + +### systemd + +If you're using systemd instead of cron to run jobs, download the [sample +systemd service +file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/systemd/borgmatic.service) +and the [sample systemd timer +file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/systemd/borgmatic.timer). +Then, from the directory where you downloaded them: + + sudo mv {borgmatic.service,borgmatic.timer} /etc/systemd/system/ + sudo systemctl enable borgmatic.timer + sudo systemctl start borgmatic.timer + +Feel free to modify the timer file based on how frequently you'd like +borgmatic to run. ## Running tests diff --git a/sample/borgmatic.cron b/sample/cron/borgmatic similarity index 100% rename from sample/borgmatic.cron rename to sample/cron/borgmatic diff --git a/sample/systemd/borgmatic.service b/sample/systemd/borgmatic.service new file mode 100644 index 0000000..443b1f0 --- /dev/null +++ b/sample/systemd/borgmatic.service @@ -0,0 +1,6 @@ +[Unit] +Description=borgmatic backup + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/borgmatic diff --git a/sample/systemd/borgmatic.timer b/sample/systemd/borgmatic.timer new file mode 100644 index 0000000..4b49d1f --- /dev/null +++ b/sample/systemd/borgmatic.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Run borgmatic backup + +[Timer] +OnCalendar=daily + +[Install] +WantedBy=timers.target