configs/arch-config/scripts/pieces/thunderbird-restore.sh

35 lines
775 B
Bash
Raw Permalink Normal View History

2023-07-22 16:34:51 +02:00
#!/usr/bin/env sh
2022-04-10 14:56:21 +02:00
set -euo pipefail
# prompt for password
echo -n "Password: "
read -s -r pass
echo
# go to home dir
cd "$HOME"
# find latest backup version
latestbackup="$(find "$HOME/Nextcloud/backups/" -name "thunderbird-backup-*\.tar.zst.gpg" | sort | tail -1)"
# decrypt backup
2023-07-22 16:34:22 +02:00
echo "$pass" | gpg --decrypt-file --batch --yes --passphrase-fd 0 "$latestbackup"
2022-04-10 14:56:21 +02:00
# name of decrypted file
latestdecrypted="${latestbackup%.gpg}"
# expand archive
tar -xvf "$latestdecrypted"
# remove unencrypted archive
rm "$latestdecrypted"
# remove current thunderbird config
rm -rf $HOME/.thunderbird/*.default-release/*
# copy configuration
cp -r $HOME/thunderbird-backup/default-release/* $HOME/.thunderbird/*.default-release/
# remove folder
rm -rf "$HOME/thunderbird-backup"