aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE13
-rw-r--r--Makefile6
-rwxr-xr-xlifeboat41
-rw-r--r--lifeboat.194
4 files changed, 154 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..46d8bd4
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2018-2019 Wolfgang Müller <vehk@vehk.de>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f2d37b8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,6 @@
+PREFIX ?= /usr/local
+
+install: lifeboat
+ install -D -m 755 -t '${DESTDIR}${PREFIX}/bin' lifeboat
+
+.PHONY: install
diff --git a/lifeboat b/lifeboat
new file mode 100755
index 0000000..244f732
--- /dev/null
+++ b/lifeboat
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+set -e
+
+errx() {
+ printf "lifeboat: %s\n" "$1" >&2
+ exit 1
+}
+
+usage() {
+ printf "usage: lifeboat repo [run|restic-cmd]\n"
+ exit 0
+}
+
+run_backup() {
+ (
+ cd "$rootdir/$repo"
+ ./run
+ for i in post sync; do
+ test -x $i && ./$i
+ done
+ )
+}
+
+rootdir=${LIFEBOAT_ROOT:-"/srv/backup/lifeboat"}
+
+test $# -lt 2 && usage
+
+repo=$1
+shift
+
+test -d "$repo" || errx "$repo: no such repository"
+
+export LIFEBOAT_REPO_NAME=$repo
+export RESTIC_REPOSITORY=$rootdir/$repo/repo
+export RESTIC_PASSWORD_FILE=$rootdir/$repo/credentials/restic
+
+case "$1" in
+ run) run_backup;;
+ *) restic "$@";;
+esac
diff --git a/lifeboat.1 b/lifeboat.1
new file mode 100644
index 0000000..f7fe710
--- /dev/null
+++ b/lifeboat.1
@@ -0,0 +1,94 @@
+.Dd October 3, 2019
+.Dt LIFEBOAT 1
+.Os
+.Sh NAME
+.Nm lifeboat
+.Nd manage and automate local restic backups
+.Sh SYNOPSIS
+.Nm
+.Ar repo
+.Ar command
+.Sh DESCRIPTION
+.Nm
+is a program that manages a set of local
+.Xr restic 1
+repositories and provides a framework
+for automating the creation and synchronization of backups.
+.Pp
+The command is any command recognized by
+.Xr restic 1 ,
+or as follows:
+.Bl -tag -width Ds
+.It Sy run
+Create a snapshot for the specified repository.
+.El
+.Sh DIRECTORY STRUCTURE
+.Nm
+keeps all its data in one directory, specified by the
+.Ev LIFEBOAT_ROOT
+environment variable.
+If unset,
+.Nm
+will fall back to
+.Pa /srv/backup/lifeboat .
+.Pp
+Each backup managed by
+.Nm
+owns a directory under
+.Ev LIFEBOAT_ROOT .
+In that directory, the program expects the following:
+.Bl -tag -width Ds
+.It Sy repo/
+A directory containing the actual
+.Xr restic 1
+repository.
+.It Sy credentials/restic
+A file containing the password for the
+.Xr restic 1
+repository.
+.It Sy run
+A shell script containing backup jobs.
+.It Sy post
+A shell script containing post-backup jobs, optional.
+.It Sy sync
+A shell script containing synchronization jobs, optional.
+.El
+.Pp
+When
+.Nm
+is invoked with the
+.Em run
+command, it will change the current directory to the backup directory, and execute the
+.Em run
+script, followed by executing
+.Em post
+and
+.Em sync ,
+if they exist.
+.Sh ENVIRONMENT
+.Nm
+will export the following environment variables for use in the
+.Em run ,
+.Em post ,
+and
+.Em sync
+scripts:
+.Bl -tag -width Ds
+.It Sy LIFEBOAT_REPO
+The name of the backup as specified on the command line.
+.It Sy RESTIC_REPOSITORY
+The path to the
+.Xr restic 1
+repository.
+.It Sy RESTIC_PASSWORD_FILE
+The path to the
+.Xr restic 1
+password file.
+.El
+.Sh SEE ALSO
+.Xr restic 1
+.Sh AUTHORS
+.An -nosplit
+.Nm
+was written by
+.An Wolfgang Müller Aq Mt vehk@vehk.de