dots/.bin/save-passwddb

22 lines
841 B
Plaintext
Raw Normal View History

2022-05-11 13:45:34 +02:00
#!/usr/bin/env bash
# Save (encrypted) password database to cloud storage
#
# Can be run manually or daily by enabling the corresponding systemd user
# service and timer, i.e.
#
# `systemctl --user enable save-passwddb.service`
# `systemctl --user enable save-passwddb.timer`
2023-12-09 20:37:50 +01:00
# 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
2023-12-09 20:37:50 +01:00
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