Add backup and restore script for evolution
This commit is contained in:
parent
c1a941806e
commit
858a966c94
36
arch-config/scripts/pieces/evolution-backup.sh
Normal file
36
arch-config/scripts/pieces/evolution-backup.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# give password as argument
|
||||
if [ $# -eq 1 ]; then
|
||||
pass=$1
|
||||
elif [ $# -eq 0 ]; then
|
||||
echo "Please provide a passphrase"
|
||||
$(exit 1); echo "$?"
|
||||
else
|
||||
echo "Please only insert one argument"
|
||||
$(exit 1); echo "$?"
|
||||
fi
|
||||
|
||||
# go to home dir
|
||||
cd "$HOME"
|
||||
|
||||
# get current date
|
||||
currdate="$(date +%Y-%m-%d)"
|
||||
|
||||
mkdir -p "$HOME/evolution-mail-backup"
|
||||
mkdir -p "$HOME/evolution-mail-backup/.config"
|
||||
mkdir -p "$HOME/evolution-mail-backup/.local"
|
||||
|
||||
cp -r "$HOME/.config/evolution/" "$HOME/evolution-mail-backup/.config/"
|
||||
cp -r "$HOME/.local/share/evolution/" "$HOME/evolution-mail-backup/.local/"
|
||||
|
||||
tar -cv -I"zstd -19 -T0" -f evolution-mail-backup-${currdate}.tar.zst evolution-mail-backup/
|
||||
|
||||
rm -rf "$HOME/evolution-mail-backup"
|
||||
|
||||
echo '$pass' | gpg -c --batch --yes --passphrase-fd 0 evolution-mail-backup-${currdate}.tar.zst
|
||||
|
||||
rm evolution-mail-backup-${currdate}.tar.zst
|
||||
|
||||
mv evolution-mail-backup-${currdate}.tar.zst.gpg "$HOME/Nextcloud/backups/"
|
38
arch-config/scripts/pieces/evolution-restore.sh
Normal file
38
arch-config/scripts/pieces/evolution-restore.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# give password as argument
|
||||
if [ $# -eq 1 ]; then
|
||||
pass=$1
|
||||
elif [ $# -eq 0 ]; then
|
||||
echo "Please provide a passphrase"
|
||||
$(exit 1); echo "$?"
|
||||
else
|
||||
echo "Please only insert one argument"
|
||||
$(exit 1); echo "$?"
|
||||
fi
|
||||
|
||||
# go to home dir
|
||||
cd "$HOME"
|
||||
|
||||
# find latest backup version
|
||||
latestbackup="$(find "$HOME/Nextcloud/backups/" -name "evolution-mail-backup-*\.tar.zst.gpg" | sort | tail -1)"
|
||||
|
||||
# decrypt backup
|
||||
echo '$pass' | gpg --decrypt-file --batch --yes --passphrase-fd 0 "$latestbackup"
|
||||
|
||||
# name of decrypted file
|
||||
latestdecrypted="${latestbackup%.gpg}"
|
||||
|
||||
# expand archive
|
||||
tar -xvf "$latestdecrypted"
|
||||
|
||||
# remove unencrypted archive
|
||||
rm "$latestdecrypted"
|
||||
|
||||
# copy configuration
|
||||
cp -r "$HOME/evolution-mail-backup/.config/" "$HOME/"
|
||||
cp -r "$HOME/evolution-mail-backup/.local/" "$HOME/"
|
||||
|
||||
# remove folder
|
||||
rm -rf "$HOME/evolution-mail-backup"
|
Loading…
Reference in New Issue
Block a user