From 6df3a61c1976f7ce57080ddc530fa800d2ba12c2 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 5 Jun 2019 21:57:28 -0300 Subject: Restore from backup in fresh volume --- scripts/box/create-backup.env.sh | 14 ++++++++++++++ scripts/box/restore-backup.env.sh | 18 ++++++++++++++++++ scripts/box/run-backup.env.sh | 13 ------------- 3 files changed, 32 insertions(+), 13 deletions(-) create mode 100755 scripts/box/create-backup.env.sh create mode 100755 scripts/box/restore-backup.env.sh delete mode 100755 scripts/box/run-backup.env.sh (limited to 'scripts/box') diff --git a/scripts/box/create-backup.env.sh b/scripts/box/create-backup.env.sh new file mode 100755 index 0000000..c9b2d3d --- /dev/null +++ b/scripts/box/create-backup.env.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +export BORG_REMOTE_PATH="${BORG_REMOTE_PATH}" +export BORG_PASSPHRASE="${BORG_PASSPHRASE}" +# The configured $BORG_REPO is already the rsync remote. +# No need to send the files after the backup is done. +echo xiu +borg create \ + --verbose \ + --stats \ + --progress \ + --compression lzma,6 \ + "${BORG_REPO}::{hostname}-{now}-${VPS_COMMIT_SHA}" \ + ${VOLUME_HOME}/* diff --git a/scripts/box/restore-backup.env.sh b/scripts/box/restore-backup.env.sh new file mode 100755 index 0000000..b12d4f0 --- /dev/null +++ b/scripts/box/restore-backup.env.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +export BORG_REMOTE_PATH="${BORG_REMOTE_PATH}" +export BORG_PASSPHRASE="${BORG_PASSPHRASE}" + +pushd "$(mktemp -d)" +ARCHIVE="$(borg list "${BORG_REPO}" --last 1 --short)" + +echo "Extracting archive ${ARCHIVE}" +borg extract \ + --verbose \ + --stats \ + --progress \ + "${BORG_REPO}"::"${ARCHIVE}" +echo "Done." + +mv home/vps/volumes/* /home/vps/volumes/ +popd diff --git a/scripts/box/run-backup.env.sh b/scripts/box/run-backup.env.sh deleted file mode 100755 index bd506e9..0000000 --- a/scripts/box/run-backup.env.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -export BORG_REMOTE_PATH="${BORG_REMOTE_PATH}" -export BORG_PASSPHRASE="${BORG_PASSPHRASE}" -# The configured $BORG_REPO is already the rsync remote. -# No need to send the files after the backup is done. -borg create \ - --verbose \ - --stats \ - --progress \ - --compression lzma,6 \ - "${BORG_REPO}::{hostname}-{now}-${VPS_COMMIT_SHA}" \ - "${VOLUME_HOME}" -- cgit v1.2.3