add unpack script to every snapshot
This commit is contained in:
parent
8345eb3217
commit
831d9ae9a2
2 changed files with 29 additions and 1 deletions
24
unpack.sh
Normal file
24
unpack.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#! /bin/zsh
|
||||
|
||||
TIMESTAMP=($(basename "$(pwd)"))
|
||||
OUTDIR="$1"
|
||||
KEYFILE="$2"
|
||||
|
||||
function die {
|
||||
>&2 echo "$2"
|
||||
exit $1
|
||||
}
|
||||
|
||||
[[ "$0" != "./unpack.sh" ]] && die 1 "This can only be executed from the snapshot directory itself."
|
||||
[[ ! -d "$OUTDIR" ]] && die 1 "The first argument must be a directory to unpack subvolumes into."
|
||||
[[ ! -f "$KEYFILE" ]] && die 1 "The second argument must be a readable keyfile."
|
||||
./check-integrity.sh || die 2 "This snapshot failed integrity checks."
|
||||
|
||||
### end of checks
|
||||
|
||||
for ARCHIVE in *btrfs.zst.aes
|
||||
do
|
||||
openssl enc -d -aes-256-cbc -pbkdf2 -salt -pass "file:$KEYFILE" < "$ARCHIVE" | zstd -d | btrfs receive "$OUTDIR" || die 3 "Failed to unpack subvolume."
|
||||
SUBVOL_NAME=${ARCHIVE%%.btrfs.zst.aes}
|
||||
mv "${OUTDIR}/${SUBVOL_NAME}" "${OUTDIR}/${SUBVOL_NAME}.${TIMESTAMP[1]}" || die 4 "Failed to rename subvolume."
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue