Update password backup scripts

Hektor Misplon 2024-06-02 14:19:56 +02:00
parent cd09cfdac0
commit 6e3cb071b8
Signed by: hektor
GPG Key ID: 5151AF79E723F21C
2 changed files with 22 additions and 2 deletions

19
.bin/restore-passwddb Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Backup existing password databases and
# database keys (using date in filename date -u
# +%Y-%m-%d_%H-%M-%S)
RCLONE_REMOTE="proton-drive"
for f in "$HOME/doc"/*.{kdbx,kdbx.key}; do
[ -e "$f" ] || continue
echo "Backing up $f to $f-$(date -u +%Y-%m-%d_%H-%M-%S)"
cp "$f" "$f-$(date -u +%Y-%m-%d_%H-%M-%S)"
done
echo "Restoring KeePassXC databases and database keys"
rclone copyto \
"$RCLONE_REMOTE:doc"/ "$HOME/doc/" \
--progress \
--include "/*.{kdbx,kdbx.key}"

View File

@ -13,8 +13,9 @@ RCLONE_REMOTE="proton-drive"
# Reference: <https://unix.stackexchange.com/questions/100871/in-a-bash-if-condition-how-to-check-whether-any-files-matching-a-simple-wildcard>
if [ 0 -lt "$(ls $HOME/doc/*.kdbx 2>/dev/null | wc -w)" ]; then
echo "Saving KeePassXC databases and database keys"
rclone copyto \
"$HOME/doc/" proton-drive:doc/ \
rclone copyto \
"$HOME/doc/" "$RCLONE_REMOTE:doc"/ \
--progress \
--include "/*.{kdbx,kdbx.key}"
else
echo "No password database found, use the following commands to restore"