summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--borg-family-0.1/debian/borg-family.postinst15
-rw-r--r--borg-family-0.1/debian/borg-family.templates8
-rw-r--r--borg-family-0.1/debian/borg-family.timer10
-rw-r--r--borg-family-0.1/debian/changelog5
-rw-r--r--borg-family-0.1/debian/files2
-rwxr-xr-xborg-family-0.1/src/sbin/bfrun29
-rw-r--r--borg-family-0.2/Makefile (renamed from borg-family-0.1/Makefile)2
-rw-r--r--borg-family-0.2/README (renamed from borg-family-0.1/README)0
-rw-r--r--borg-family-0.2/debian/borg-family.config (renamed from borg-family-0.1/debian/borg-family.config)1
-rw-r--r--borg-family-0.2/debian/borg-family.cron.daily5
-rw-r--r--borg-family-0.2/debian/borg-family.docs (renamed from borg-family-0.1/debian/borg-family.docs)0
-rw-r--r--borg-family-0.2/debian/borg-family.examples (renamed from borg-family-0.1/debian/borg-family.examples)0
-rw-r--r--borg-family-0.2/debian/borg-family.init (renamed from borg-family-0.1/debian/borg-family.init)2
-rw-r--r--borg-family-0.2/debian/borg-family.manpages (renamed from borg-family-0.1/debian/borg-family.manpages)0
-rw-r--r--borg-family-0.2/debian/borg-family.postinst17
-rw-r--r--borg-family-0.2/debian/borg-family.postrm (renamed from borg-family-0.1/debian/borg-family.postrm)2
-rw-r--r--borg-family-0.2/debian/borg-family.service (renamed from borg-family-0.1/debian/borg-family.service)0
-rw-r--r--borg-family-0.2/debian/borg-family.substvars (renamed from borg-family-0.1/debian/borg-family.substvars)0
-rw-r--r--borg-family-0.2/debian/borg-family.templates16
-rw-r--r--borg-family-0.2/debian/changelog5
-rw-r--r--borg-family-0.2/debian/compat (renamed from borg-family-0.1/debian/compat)0
-rw-r--r--borg-family-0.2/debian/control (renamed from borg-family-0.1/debian/control)0
-rw-r--r--borg-family-0.2/debian/debhelper-build-stamp (renamed from borg-family-0.1/debian/debhelper-build-stamp)0
-rw-r--r--borg-family-0.2/debian/files2
-rwxr-xr-xborg-family-0.2/debian/rules (renamed from borg-family-0.1/debian/rules)0
-rw-r--r--borg-family-0.2/debian/source/format (renamed from borg-family-0.1/debian/source/format)0
-rw-r--r--borg-family-0.2/doc/examples/envvars (renamed from borg-family-0.1/doc/examples/envvars)0
l---------borg-family-0.2/doc/man/bfenv.1 (renamed from borg-family-0.1/doc/man/bfenv.1)0
-rw-r--r--borg-family-0.2/doc/man/bfrun.1 (renamed from borg-family-0.1/doc/man/bfrun.1)0
l---------borg-family-0.2/doc/man/bfwhat.1 (renamed from borg-family-0.1/doc/man/bfwhat.1)0
-rwxr-xr-xborg-family-0.2/src/etc/bfhooks (renamed from borg-family-0.1/src/etc/bfhooks)16
-rw-r--r--borg-family-0.2/src/etc/confvars (renamed from borg-family-0.1/src/etc/confvars)1
-rw-r--r--borg-family-0.2/src/etc/excludes.d/home (renamed from borg-family-0.1/src/etc/excludes.d/home)0
-rw-r--r--borg-family-0.2/src/etc/excludes.d/rootfs (renamed from borg-family-0.1/src/etc/excludes.d/rootfs)0
-rwxr-xr-xborg-family-0.2/src/sbin/bfenv (renamed from borg-family-0.1/src/sbin/bfenv)0
-rwxr-xr-xborg-family-0.2/src/sbin/bfenv231
-rwxr-xr-xborg-family-0.2/src/sbin/bfrun32
-rwxr-xr-xborg-family-0.2/src/sbin/bfwhat (renamed from borg-family-0.1/src/sbin/bfwhat)0
38 files changed, 128 insertions, 73 deletions
diff --git a/borg-family-0.1/debian/borg-family.postinst b/borg-family-0.1/debian/borg-family.postinst
deleted file mode 100644
index 5bf8c69..0000000
--- a/borg-family-0.1/debian/borg-family.postinst
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-set -e
-
-EVFILE=/etc/borg-family/envvars
-
-if [ "$1" = configure ]; then
- . /usr/share/debconf/confmodule
- unset BORG_REPO
- db_get borg-family/borg-repo && BORG_REPO="$RET"
- db_stop
- [ -f "$EVFILE" ] || install -m 644 /usr/share/doc/borg-family/examples/envvars "$EVFILE"
- [ -n "$BORG_REPO" ] && sed --in-place -e 's#^export BORG_REPO=.*$#export BORG_REPO="'$BORG_REPO'"#' -- "$EVFILE"
-fi
-
-#DEBHELPER#
diff --git a/borg-family-0.1/debian/borg-family.templates b/borg-family-0.1/debian/borg-family.templates
deleted file mode 100644
index b17ce60..0000000
--- a/borg-family-0.1/debian/borg-family.templates
+++ /dev/null
@@ -1,8 +0,0 @@
-Template: borg-family/borg-repo
-Type: string
-Description: Borg repository URL:
- Please set the backup destination.
- .
- It will be exported to BORG_REPO by bfrun for borg commands.
- Could be 'ssh://user@host:port/abspath/to/repo', or 'user@host:relpath/to/repo', see man borg.
-
diff --git a/borg-family-0.1/debian/borg-family.timer b/borg-family-0.1/debian/borg-family.timer
deleted file mode 100644
index 14a848a..0000000
--- a/borg-family-0.1/debian/borg-family.timer
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Run borg-family backup
-
-[Timer]
-OnCalendar=daily
-Persistent=true
-
-[Install]
-WantedBy=timers.target
-
diff --git a/borg-family-0.1/debian/changelog b/borg-family-0.1/debian/changelog
deleted file mode 100644
index e2329ed..0000000
--- a/borg-family-0.1/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-borg-family (0.1-1) UNRELEASED; urgency=medium
-
- * Initial release.
-
- -- Ludovic Pouzenc <ludovic@pouzenc.fr> Sat, 28 Nov 2020 17:07:53 +0100
diff --git a/borg-family-0.1/debian/files b/borg-family-0.1/debian/files
deleted file mode 100644
index 225c048..0000000
--- a/borg-family-0.1/debian/files
+++ /dev/null
@@ -1,2 +0,0 @@
-borg-family_0.1-1_all.deb admin optional
-borg-family_0.1-1_amd64.buildinfo admin optional
diff --git a/borg-family-0.1/src/sbin/bfrun b/borg-family-0.1/src/sbin/bfrun
deleted file mode 100755
index c02187a..0000000
--- a/borg-family-0.1/src/sbin/bfrun
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-source bfenv
-bfwhat | while IFS=' ' read -r mpe dev; do
- mp=$(echo -e "$mpe") # mp: interpret escapings that may be present in /proc/mounts (\040 for space...)
- name=${mp// /_}; # name: replace space by underscore
- name=${mp//\//-}; name=${name/-/} # name: replace slash by dash, remove the leading one
- if [[ "$mp $name $dev" =~ "--" || "$mp $name $dev" =~ ".." || "$mp $name $dev" =~ "[|&;()<>]" ]]; then
- echo "Skipping $mpe because of shell unsafe characters" >&2
- continue
- fi
-
- comment=$(blkid -- "$dev")
- if [ -r "/etc/borg-family/excludes.d/$name" ]; then
- runtime_args=( --comment="$comment" --exclude-from="/etc/borg-family/excludes.d/$name" )
- else
- runtime_args=( --comment="$comment" )
- fi
-
- bfhooks before "$name" && \
- borg create "${runtime_args[@]}" "${borg_create_opts[@]}" "::{hostname}-$name-{now:%Y-%m-%d}" "$mp"
- rc1=$?
- bfhooks after "$name"
- rc2=$?
- if [ "$rc1" -ne 0 -o "$rc2" -ne 0 ]; then
- echo "Errors during $name backup, return codes $rc1 (bfhook before && borg create) and $rc2 (bfhook after)" >&2
- else
- [ "x$quiet" == "x1" ] || echo "Success for $name backup"
- fi
-done
diff --git a/borg-family-0.1/Makefile b/borg-family-0.2/Makefile
index ff88bdd..2230ee9 100644
--- a/borg-family-0.1/Makefile
+++ b/borg-family-0.2/Makefile
@@ -1,5 +1,5 @@
PKGNAME=borg-family
-VERSION=0.1
+VERSION=0.2
INSTALL=install
INSTALL_PROGRAM=$(INSTALL)
diff --git a/borg-family-0.1/README b/borg-family-0.2/README
index e69de29..e69de29 100644
--- a/borg-family-0.1/README
+++ b/borg-family-0.2/README
diff --git a/borg-family-0.1/debian/borg-family.config b/borg-family-0.2/debian/borg-family.config
index d0e4f26..7483dd7 100644
--- a/borg-family-0.1/debian/borg-family.config
+++ b/borg-family-0.2/debian/borg-family.config
@@ -1,4 +1,5 @@
#!/bin/sh -e
. /usr/share/debconf/confmodule
db_input critical borg-family/borg-repo || true
+db_input critical borg-family/borg-repo2 || true
db_go
diff --git a/borg-family-0.2/debian/borg-family.cron.daily b/borg-family-0.2/debian/borg-family.cron.daily
new file mode 100644
index 0000000..d08f88a
--- /dev/null
+++ b/borg-family-0.2/debian/borg-family.cron.daily
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ -x /usr/sbin/bfrun ]; then
+ /usr/bin/systemd-inhibit --why="Prevent interrupting backup" /usr/sbin/bfrun
+fi
diff --git a/borg-family-0.1/debian/borg-family.docs b/borg-family-0.2/debian/borg-family.docs
index e845566..e845566 100644
--- a/borg-family-0.1/debian/borg-family.docs
+++ b/borg-family-0.2/debian/borg-family.docs
diff --git a/borg-family-0.1/debian/borg-family.examples b/borg-family-0.2/debian/borg-family.examples
index e002ac5..e002ac5 100644
--- a/borg-family-0.1/debian/borg-family.examples
+++ b/borg-family-0.2/debian/borg-family.examples
diff --git a/borg-family-0.1/debian/borg-family.init b/borg-family-0.2/debian/borg-family.init
index 72e9267..3b7b326 100644
--- a/borg-family-0.1/debian/borg-family.init
+++ b/borg-family-0.2/debian/borg-family.init
@@ -13,5 +13,5 @@
case "$1" in
start|stop|restart|reload|status|force-reload)
- log_action_msg "This is a stub, you shuld run bfrun from cron if not using systemd borg-family.timer" ;;
+ log_action_msg "This is a stub, you should run bfrun from cron if not using systemd borg-family.timer" ;;
esac
diff --git a/borg-family-0.1/debian/borg-family.manpages b/borg-family-0.2/debian/borg-family.manpages
index 160e2fa..160e2fa 100644
--- a/borg-family-0.1/debian/borg-family.manpages
+++ b/borg-family-0.2/debian/borg-family.manpages
diff --git a/borg-family-0.2/debian/borg-family.postinst b/borg-family-0.2/debian/borg-family.postinst
new file mode 100644
index 0000000..e900217
--- /dev/null
+++ b/borg-family-0.2/debian/borg-family.postinst
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -e
+
+if [ "$1" = configure ]; then
+ . /usr/share/debconf/confmodule
+ unset BORG_REPO
+ for i in "" 2
+ do
+ db_get borg-family/borg-repo$i && BORG_REPO="$RET"
+ ENVFILE=/etc/borg-family/envvars$i
+ [ -f "$ENVFILE" ] || install -m 644 /usr/share/doc/borg-family/examples/envvars "$ENVFILE"
+ [ -n "$BORG_REPO" ] && sed --in-place -e 's#^export BORG_REPO=.*$#export BORG_REPO="'$BORG_REPO'"#' -- "$ENVFILE"
+ done
+ db_stop
+fi
+
+#DEBHELPER#
diff --git a/borg-family-0.1/debian/borg-family.postrm b/borg-family-0.2/debian/borg-family.postrm
index 5ae54c6..cf11e70 100644
--- a/borg-family-0.1/debian/borg-family.postrm
+++ b/borg-family-0.2/debian/borg-family.postrm
@@ -4,7 +4,7 @@ set -e
if [ "$1" = "purge" ]; then
. /usr/share/debconf/confmodule
db_purge
- rm -f /etc/borg-family/envvars
+ rm -f /etc/borg-family/envvars /etc/borg-family/envvars2
fi
#DEBHELPER#
diff --git a/borg-family-0.1/debian/borg-family.service b/borg-family-0.2/debian/borg-family.service
index f6aab42..f6aab42 100644
--- a/borg-family-0.1/debian/borg-family.service
+++ b/borg-family-0.2/debian/borg-family.service
diff --git a/borg-family-0.1/debian/borg-family.substvars b/borg-family-0.2/debian/borg-family.substvars
index a595723..a595723 100644
--- a/borg-family-0.1/debian/borg-family.substvars
+++ b/borg-family-0.2/debian/borg-family.substvars
diff --git a/borg-family-0.2/debian/borg-family.templates b/borg-family-0.2/debian/borg-family.templates
new file mode 100644
index 0000000..4c1a6c9
--- /dev/null
+++ b/borg-family-0.2/debian/borg-family.templates
@@ -0,0 +1,16 @@
+Template: borg-family/borg-repo
+Type: string
+Description: Borg repository URL:
+ Please set the backup destination.
+ .
+ It will be exported to BORG_REPO by bfrun for borg commands.
+ Could be 'ssh://user@host:port/abspath/to/repo', or 'user@host:relpath/to/repo', see man borg.
+
+Template: borg-family/borg-repo2
+Type: string
+Description: Second Borg repository URL:
+ Please set the second backup destination.
+ .
+ It will be exported to BORG_REPO by bfrun for borg commands.
+ Could be 'ssh://user@host:port/abspath/to/repo', or 'user@host:relpath/to/repo', see man borg.
+
diff --git a/borg-family-0.2/debian/changelog b/borg-family-0.2/debian/changelog
new file mode 100644
index 0000000..b88eba1
--- /dev/null
+++ b/borg-family-0.2/debian/changelog
@@ -0,0 +1,5 @@
+borg-family (0.2-1) UNRELEASED; urgency=medium
+
+ * New upstream release.
+
+ -- Ludovic Pouzenc <ludovic@pouzenc.fr> Tue, 15 Jun 2021 15:59:45 +0200
diff --git a/borg-family-0.1/debian/compat b/borg-family-0.2/debian/compat
index f599e28..f599e28 100644
--- a/borg-family-0.1/debian/compat
+++ b/borg-family-0.2/debian/compat
diff --git a/borg-family-0.1/debian/control b/borg-family-0.2/debian/control
index 3ca323f..3ca323f 100644
--- a/borg-family-0.1/debian/control
+++ b/borg-family-0.2/debian/control
diff --git a/borg-family-0.1/debian/debhelper-build-stamp b/borg-family-0.2/debian/debhelper-build-stamp
index e8dd97e..e8dd97e 100644
--- a/borg-family-0.1/debian/debhelper-build-stamp
+++ b/borg-family-0.2/debian/debhelper-build-stamp
diff --git a/borg-family-0.2/debian/files b/borg-family-0.2/debian/files
new file mode 100644
index 0000000..120b6c0
--- /dev/null
+++ b/borg-family-0.2/debian/files
@@ -0,0 +1,2 @@
+borg-family_0.2-1_all.deb admin optional
+borg-family_0.2-1_amd64.buildinfo admin optional
diff --git a/borg-family-0.1/debian/rules b/borg-family-0.2/debian/rules
index cbe925d..cbe925d 100755
--- a/borg-family-0.1/debian/rules
+++ b/borg-family-0.2/debian/rules
diff --git a/borg-family-0.1/debian/source/format b/borg-family-0.2/debian/source/format
index 163aaf8..163aaf8 100644
--- a/borg-family-0.1/debian/source/format
+++ b/borg-family-0.2/debian/source/format
diff --git a/borg-family-0.1/doc/examples/envvars b/borg-family-0.2/doc/examples/envvars
index 99f7139..99f7139 100644
--- a/borg-family-0.1/doc/examples/envvars
+++ b/borg-family-0.2/doc/examples/envvars
diff --git a/borg-family-0.1/doc/man/bfenv.1 b/borg-family-0.2/doc/man/bfenv.1
index 080be00..080be00 120000
--- a/borg-family-0.1/doc/man/bfenv.1
+++ b/borg-family-0.2/doc/man/bfenv.1
diff --git a/borg-family-0.1/doc/man/bfrun.1 b/borg-family-0.2/doc/man/bfrun.1
index efc42a7..efc42a7 100644
--- a/borg-family-0.1/doc/man/bfrun.1
+++ b/borg-family-0.2/doc/man/bfrun.1
diff --git a/borg-family-0.1/doc/man/bfwhat.1 b/borg-family-0.2/doc/man/bfwhat.1
index 080be00..080be00 120000
--- a/borg-family-0.1/doc/man/bfwhat.1
+++ b/borg-family-0.2/doc/man/bfwhat.1
diff --git a/borg-family-0.1/src/etc/bfhooks b/borg-family-0.2/src/etc/bfhooks
index 5b6b204..c7ce378 100755
--- a/borg-family-0.1/src/etc/bfhooks
+++ b/borg-family-0.2/src/etc/bfhooks
@@ -6,6 +6,12 @@ mount_bind_rootfs() {
fi
}
+mount_efi() {
+ if ! mount | grep -q /boot/efi; then
+ mount /boot/efi
+ fi
+}
+
umount_bind_rootfs() {
if mount | grep -q /rootfs; then
umount /rootfs || lsof -n | grep /rootfs
@@ -13,15 +19,25 @@ umount_bind_rootfs() {
fi
}
+umount_efi() {
+ if mount | grep -q /boot/efi; then
+ umount /boot/efi || lsof -n | grep /boot/efi
+ fi
+}
+
case $1 in
before)
+ echo "Start of backup: $2 to $BORG_REPO"
case $2 in
rootfs) apt-get clean || true; mount_bind_rootfs;;
+ boot-efi) mount_efi ;;
esac
;;
after)
case $2 in
rootfs) umount_bind_rootfs ;;
+ boot-efi) umount_efi ;;
esac
+ echo "End of backup: $2 to $BORG_REPO"
;;
esac
diff --git a/borg-family-0.1/src/etc/confvars b/borg-family-0.2/src/etc/confvars
index f737648..4737195 100644
--- a/borg-family-0.1/src/etc/confvars
+++ b/borg-family-0.2/src/etc/confvars
@@ -1,5 +1,4 @@
# This file is used by bfenv and bfrun (bash scripts)
borg_init_opts=( -e repokey-blake2 --make-parent-dirs -v )
-borg_check_opts=( --last $((1+$(bfwhat | wc -l) )) -v )
borg_create_opts=( --one-file-system --compression zstd --exclude-caches --exclude-if-present=NOBACKUPDIR.TAG --keep-exclude-tags --list --filter=AMEi-x --stats --show-rc -v )
quiet=0
diff --git a/borg-family-0.1/src/etc/excludes.d/home b/borg-family-0.2/src/etc/excludes.d/home
index c7aead3..c7aead3 100644
--- a/borg-family-0.1/src/etc/excludes.d/home
+++ b/borg-family-0.2/src/etc/excludes.d/home
diff --git a/borg-family-0.1/src/etc/excludes.d/rootfs b/borg-family-0.2/src/etc/excludes.d/rootfs
index b61797b..b61797b 100644
--- a/borg-family-0.1/src/etc/excludes.d/rootfs
+++ b/borg-family-0.2/src/etc/excludes.d/rootfs
diff --git a/borg-family-0.1/src/sbin/bfenv b/borg-family-0.2/src/sbin/bfenv
index 756ef62..756ef62 100755
--- a/borg-family-0.1/src/sbin/bfenv
+++ b/borg-family-0.2/src/sbin/bfenv
diff --git a/borg-family-0.2/src/sbin/bfenv2 b/borg-family-0.2/src/sbin/bfenv2
new file mode 100755
index 0000000..6e5adeb
--- /dev/null
+++ b/borg-family-0.2/src/sbin/bfenv2
@@ -0,0 +1,31 @@
+#!/bin/bash
+umask 0077
+source /etc/borg-family/confvars
+source /etc/borg-family/envvars2
+PATH="/etc/borg-family:$PATH"
+
+if [ \! -r /etc/borg-family/passphrase2 ]; then
+ echo "No passphrase2 (repokey) found, creating a new one" >&2
+ touch /etc/borg-family/passphrase2
+ chmod 600 /etc/borg-family/passphrase2
+ pwgen 32 1 >> /etc/borg-family/passphrase2
+ ls -l /etc/borg-family/passphrase2 >&2
+ echo "You NEED to store it in a password manager to be able to restore backups" >&2
+fi
+
+if [ \! -r /etc/borg-family/id_rsa_borg ]; then
+ echo "No SSH key found, creating a new one" >&2
+ ssh-keygen -N "" -C "$(id -un)_borg@$(hostname)" -f /etc/borg-family/id_rsa_borg \
+ && cat /etc/borg-family/id_rsa_borg.pub
+fi
+
+LANG=C borg init "${borg_init_opts[@]}" 2>&1 | grep -vE '^A repository already exists' >&2
+
+if ! borg list > /dev/null; then
+ echo "Showing BORG_* env variables (see /etc/borg-family/envvars) :" >&2
+ env | grep ^BORG_ >&2
+ echo "End of BORG_* env variables" >&2
+ echo >&2
+ echo "Can't access to or check the borg repository, exiting, no backup made" >&2
+ exit 1
+fi
diff --git a/borg-family-0.2/src/sbin/bfrun b/borg-family-0.2/src/sbin/bfrun
new file mode 100755
index 0000000..b0f80dd
--- /dev/null
+++ b/borg-family-0.2/src/sbin/bfrun
@@ -0,0 +1,32 @@
+#!/bin/bash
+for e in bfenv bfenv2
+do
+ source $e
+ bfwhat | while IFS=' ' read -r mpe dev; do
+ mp=$(echo -e "$mpe") # mp: interpret escapings that may be present in /proc/mounts (\040 for space...)
+ name=${mp// /_}; # name: replace space by underscore
+ name=${mp//\//-}; name=${name/-/} # name: replace slash by dash, remove the leading one
+ if [[ "$mp $name $dev" =~ "--" || "$mp $name $dev" =~ ".." || "$mp $name $dev" =~ "[|&;()<>]" ]]; then
+ echo "Skipping $mpe because of shell unsafe characters" >&2
+ continue
+ fi
+
+ comment=$(blkid -- "$dev")
+ if [ -r "/etc/borg-family/excludes.d/$name" ]; then
+ runtime_args=( --comment="$comment" --exclude-from="/etc/borg-family/excludes.d/$name" )
+ else
+ runtime_args=( --comment="$comment" )
+ fi
+
+ bfhooks before "$name" && \
+ borg create "${runtime_args[@]}" "${borg_create_opts[@]}" "::{hostname}-$name-{now:%Y-%m-%d}" "$mp"
+ rc1=$?
+ bfhooks after "$name"
+ rc2=$?
+ if [ "$rc1" -ne 0 -o "$rc2" -ne 0 ]; then
+ echo "Errors during $name backup, return codes $rc1 (bfhook before && borg create) and $rc2 (bfhook after)" >&2
+ else
+ [ "x$quiet" == "x1" ] || echo "Success for $name backup"
+ fi
+ done
+done
diff --git a/borg-family-0.1/src/sbin/bfwhat b/borg-family-0.2/src/sbin/bfwhat
index bf9cf4d..bf9cf4d 100755
--- a/borg-family-0.1/src/sbin/bfwhat
+++ b/borg-family-0.2/src/sbin/bfwhat