From ec4b86a97d310d1b11c04d5c602416b8ba24f9f9 Mon Sep 17 00:00:00 2001 From: Erik Westrup Date: Fri, 31 Aug 2018 20:24:27 +0200 Subject: [PATCH] Added Makefile for installation of files --- Makefile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 8 ++++++++ 2 files changed, 55 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e8c4eb --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +# Not file targets. +.PHONY: help install install-scripts install-conf install-exclude install-systemd + +### Macros ### +SRCS_SCRIPTS = $(filter-out %cron_mail, $(wildcard usr/local/sbin/*)) +SRCS_CONF = $(wildcard etc/restic/*) +SRCS_EXCLUDE = .backup_exclude +SRCS_SYSTEMD = $(wildcard etc/systemd/system/*) + +# Just set PREFIX in envionment, like +# $ PREFIX=/tmp/test make +DEST_SCRIPTS = $(PREFIX)/usr/local/sbin +DEST_CONF = $(PREFIX)/etc/restic +DEST_EXCLUDE = $(PREFIX)/ +DEST_SYSTEMD = $(PREFIX)/etc/systemd/system + + +### Targets ### +# target: all - Default target. +all: install + +# target: help - Display all targets. +help: + @egrep "#\starget:" [Mm]akefile | sed 's/\s-\s/\t\t\t/' | cut -d " " -f3- | sort -d + +# target: install - Install all files +install: install-scripts install-conf install-exclude install-systemd + + +# target: install-scripts - Install executables. +install-scripts: + install -d $(DEST_SCRIPTS) + install -m 744 $(SRCS_SCRIPTS) $(DEST_SCRIPTS) + +# target: install-conf - Install restic configuration files. +install-conf: + install -d $(DEST_CONF) -m 700 + install $(SRCS_CONF) $(DEST_CONF) + +# target: install-exclude - Install backup exclude file. +install-exclude: + install $(SRCS_EXCLUDE) $(DEST_EXCLUDE) + +# target: install-systemd - Install systemd timer and service files +install-systemd: + install -d $(DEST_SYSTEMD) + install $(SRCS_SYSTEMD) $(DEST_SYSTEMD) diff --git a/README.md b/README.md index b9544c7..1a1c91b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,14 @@ Note, you can use any of the supported [storage backends](https://restic.readthe ## Set up +Tip: The steps in this section will instruct you to copy files from this repo to system directories. If you don't want to do this manually, you can use the Makefile: + +```bash +$ git clone git@github.com:erikw/restic-systemd-automatic-backup.git +$ cd restic-systemd-automatic-backup +$ sudo make install +```` + ### 1. Create Backblaze B2 account First, see this official Backblaze [tutorial](https://help.backblaze.com/hc/en-us/articles/115002880514-How-to-configure-Backblaze-B2-with-Restic-on-Linux) on restic, and follow the instructions ("Create Backblaze account with B2 enabled"")there on how to create a new B2 bucket.