diff options
author | EuAndreh <eu@euandre.org> | 2019-06-05 21:57:28 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-06-05 21:57:28 -0300 |
commit | 6df3a61c1976f7ce57080ddc530fa800d2ba12c2 (patch) | |
tree | fd8aa35db5a38780604f476ba4e1c8306a6dc370 /scripts/box | |
parent | Add Ansible to shell derivation (diff) | |
download | server-6df3a61c1976f7ce57080ddc530fa800d2ba12c2.tar.gz server-6df3a61c1976f7ce57080ddc530fa800d2ba12c2.tar.xz |
Restore from backup in fresh volume
Diffstat (limited to 'scripts/box')
-rwxr-xr-x | scripts/box/create-backup.env.sh (renamed from scripts/box/run-backup.env.sh) | 3 | ||||
-rwxr-xr-x | scripts/box/restore-backup.env.sh | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/scripts/box/run-backup.env.sh b/scripts/box/create-backup.env.sh index bd506e9..c9b2d3d 100755 --- a/scripts/box/run-backup.env.sh +++ b/scripts/box/create-backup.env.sh @@ -4,10 +4,11 @@ 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}" + ${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 |