From 54f887f7d4bb33dda38b23d91fab211daecb798d Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Sat, 9 Dec 2023 20:37:50 +0100 Subject: [PATCH] Save all KeePassXC databases --- .bin/save-passwddb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.bin/save-passwddb b/.bin/save-passwddb index a1eaeff..89368ae 100755 --- a/.bin/save-passwddb +++ b/.bin/save-passwddb @@ -8,9 +8,14 @@ # `systemctl --user enable save-passwddb.service` # `systemctl --user enable save-passwddb.timer` -if [ -f "$HOME/doc/passwd.kdbx" ]; then - rclone copy "$HOME/doc/passwd.kdbx" google-drive: +# 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 + rclone copy "$HOME/doc" google-drive: --include "*.kdbx" + rclone copy "$HOME/doc" google-drive: --include "*.kdbx.key" else - echo "Password database not found, use 'rclone copy google-drive:passwd.kdbx $HOME/doc/passwd.kdbx' to restore" + echo "No password database found, use the following commands to restore" + echo "" + echo "rclone copy google-drive: \"$HOME/doc\" --include \"*.kdbx\"" + echo "rclone copy google-drive: \"$HOME/doc\" --include \"*.kdbx.key\"" exit 1 fi