Intro
I keep my passwords in the KeePassXC DB and use Dropbox to synchronising it between multiple computers (and phones). It has been working fine for years, until I decided to try set RPi as a desktop. Dropbox does not provide a client for Arm architecture. However, as quite often in the world of open source, there is an alternative. Rclone is a tool allowing you to manage files in over 70 cloud provider, including Dropbox.
Software is easy to install and configure. Just run rclone config and follow prompts, choose Dropbox, authenticate via browser, as documented in the Dropbox section of the project website.
Sync
For syncing one file, rarely changed, a simple script around rclone is good enough. It provides 2 functions: pull and push.
#!/bin/bash
REMOTE="dropbox:path/to"
REMOTE_PATH="${REMOTE}/YourDB.kdbx"
LOCAL_PATH="${HOME}/keepass"
LOCAL="${LOCAL_PATH}/YourDB.kdbx"
case "$1" in
pull)
rclone copy "${REMOTE}" "${LOCAL_PATH}"
echo "Pulled from Dropbox"
;;
push)
rclone copy "${LOCAL}" "${REMOTE_PATH}"
echo "Pushed to Dropbox"
;;
*)
echo "Usage: $0 pull|push"
;;
esac
The script assumes that the name of the remote was set to dropbox and the local copy is stored in the ~/keepass directory. Note, that for the copy source is the name of the file, but destation is the folder.
Cronjobs
To to mimize a chance of reading outdated passwords it's worth to automated the pull step. Just pull, because KeePassXC handles conflicts well at the application level (it can merge databases), but rclone itself is not conflict-aware. Automated push can overwrite changes from another machines, or copy a corrupted file.
# Automated sync every half-hour */30 * * * * rclone copy dropbox:path/to/YourDB.kdbx ~/keepass/ --log-file=~/.local/var/log/rclone-keepass.log --log-level ERROR # Extra daily backup 3 3 * * * rclone copy dropbox:path/to/YourDB.kdbx ~/keepass/$(date +\%Y-\%m-\%d)/ --log-file=~/.local/var/log/rclone-keepass-backup.log --log-level ERROR
No comments:
Post a Comment