full Restore should work now TM
This commit is contained in:
parent
805449870e
commit
3e84ea65e3
36
btrbk
36
btrbk
|
@ -41,6 +41,8 @@ function bkRun {
|
|||
}
|
||||
|
||||
function runRestore {
|
||||
echo "not implemented yet™"
|
||||
exit 1
|
||||
if [ -z ${rDate+x} ]; then
|
||||
for o in ${!VOLNAME[@]}; do
|
||||
if [[ "${VOLNAME[$o]}" = "${restoreVol}" ]]; then
|
||||
|
@ -55,8 +57,6 @@ function runRestore {
|
|||
# mount -o subvolid=1 -U $BTRFSUUID /mnt/$BTRFSUUID
|
||||
# btrfs subvolume delete /mnt/$BTRFSUUID/
|
||||
fi
|
||||
echo "not implemented yet™"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function runFullRestore {
|
||||
|
@ -65,10 +65,10 @@ function runFullRestore {
|
|||
[yY]) rclone config;;
|
||||
*) ;;
|
||||
esac
|
||||
echo "specify the remote path with trailing slash [remote:/path/to/backupdir/]"
|
||||
echo "Specify the remote path with trailing slash [remote:/path/to/backupdir/]"
|
||||
read -r -p "Dir: " rcloneDir
|
||||
rclone copy $rcloneDir"config/btrbk.conf" /etc/btrbk.conf
|
||||
echo "Supply Path of your gpg public and secret key"
|
||||
echo "Enter Path of your gpg public and secret key"
|
||||
read -r -p "Publickey: " gpgPub
|
||||
read -r -p "Secretkey: " gpgPriv
|
||||
gpg --import $gpgPub
|
||||
|
@ -76,20 +76,18 @@ function runFullRestore {
|
|||
|
||||
source /etc/btrbk.conf
|
||||
local bkSuffix=("${INCR[0]}" "${FULL[0]}")
|
||||
btrfs subvolume create $restoreDir"snapshots"
|
||||
lastBk=$(rclone lsf $RCLONEDIR | grep ....-..-${FULL[0]} | tail -n -1 | sed "s/\/$//")
|
||||
if rclone lsf $RCLONEDIR$($lastBk | sed "s/${FULL[0]}/${INCR[0]}") > /dev/null 2>&1; then
|
||||
btrfs subvolume create $restoreDir"restore"
|
||||
lastBkDate=$(rclone lsf "$RCLONEDIR" | grep ....-..-${FULL[0]} | tail -n -1 | sed "s/full\/$//")
|
||||
for i in ${!bkSuffix[@]}; do
|
||||
mapfile -t bkFile < <(rclone lsf "$RCLONEDIR$lastBk${bkSuffix[$i]}/")
|
||||
mapfile -t bkFile < <(rclone lsf "$RCLONEDIR$lastBkDate${bkSuffix[$i]}" 2>/dev/null)
|
||||
for o in ${!bkFile[@]}; do
|
||||
rclone rcat "$RCLONEDIR$lastBk${bkSuffix[$i]}/${bkFile[$o]}" | gpg --batch -d $PUBKEY -o - | btrfs recive $restoreDir"snapshots"
|
||||
rclone rcat "$RCLONEDIR$lastBkDate${bkSuffix[$i]}/${bkFile[$o]}" | gpg --batch -d $PUBKEY -o - | btrfs receive $restoreDir"restore"
|
||||
done
|
||||
done
|
||||
for i in ${!SUBVOLS[@]}; do
|
||||
|
||||
rclone rcat /mnt/bk/root-bk.gpg | gpg --batch -d --passphrase-file /mnt/bk/gpgpass -o - | btrfs receive /mnt/restore
|
||||
for i in ${!VOLNAME[@]}; do
|
||||
newestSnap=$(ls -a $restoreDir"restore" | grep ${VOLNAME[$i]}.\....-..- | tail -n -1 )
|
||||
btrfs subvolume snapshot $restoreDir"restore/"$newestSnap $restoreDir${VOLNAME[$i]}
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
function getSnap {
|
||||
|
@ -111,9 +109,7 @@ function testConf {
|
|||
fi
|
||||
if rclone ls $RCLONEDIR > /dev/null 2>&1; then
|
||||
if gpg --list-key $PUBKEY > /dev/null 2>&1; then
|
||||
if [ $fullRestore=1 ]; then
|
||||
runFullRestore
|
||||
elif [ $restore=1 ]; then
|
||||
if [ $restore=1 ]; then
|
||||
runRestore
|
||||
elif [ $backup=1 ]; then
|
||||
testDate
|
||||
|
@ -156,6 +152,7 @@ function echoHelp {
|
|||
|
||||
options=$(getopt -l "backup,force,date:,restore:,full-restore:,help" -o "bfd:r:x:h" -- "$@")
|
||||
eval set -- "$options"
|
||||
|
||||
while true; do
|
||||
case $1 in
|
||||
-b|--backup) backup=1; shift;;
|
||||
|
@ -170,4 +167,9 @@ while true; do
|
|||
esac
|
||||
shift
|
||||
done
|
||||
testConf
|
||||
|
||||
if [ $fullRestore=1 ]; then
|
||||
runFullRestore
|
||||
else
|
||||
testConf
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue