From 6e3cb071b8d40b4ba359a99576ec91e19fa1b3c3 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Sun, 2 Jun 2024 14:19:56 +0200 Subject: [PATCH] Update password backup scripts --- .bin/restore-passwddb | 19 +++++++++++++++++++ .bin/save-passwddb | 5 +++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 .bin/restore-passwddb diff --git a/.bin/restore-passwddb b/.bin/restore-passwddb new file mode 100755 index 0000000..0c99639 --- /dev/null +++ b/.bin/restore-passwddb @@ -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}" diff --git a/.bin/save-passwddb b/.bin/save-passwddb index bf705fb..6966b3e 100755 --- a/.bin/save-passwddb +++ b/.bin/save-passwddb @@ -13,8 +13,9 @@ RCLONE_REMOTE="proton-drive" # Reference: 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"