Keepuppy
KeePass database SFTP sync
Keepuppy is a Python script/package I hacked together to keep database files in sync across multiple clients via an SFTP server. It can also be configured to call a script when the local file is updated. A script for restarting KeePassX on OS X is provided.
It's also an experiment in:-
- Robust testing with nose and mock.
- Configuration via envdir.
- Version management using bumpversion.
- Continuous integration via github and travis-ci.
- Python packaging for PyPi.
- Badge-driven development :)
Launchd script
To run it periodically on OS X, here is a sample launchd
script. For more information on periodic job management with
launchd
check out this detailed article.
This script will run keepuppy_sync.py
, passing configuration environment variables stored in ~/envdir/keepuppy
via
envdir
, all from a virtualenv
called keepuppy
. The job runs every 5 minutes and outputs to log files at
/tmp/keepuppy.log
and /tmp/keepuppy_error.log
.
You will need to change the program arguments to match your user, envdir
and virtualenv
paths.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.wamonite.keepuppy</string>
<key>ProgramArguments</key>
<array>
<string>/Users/warren/.virtualenvs/keepuppy/bin/envdir</string>
<string>/Users/warren/envdir/keepuppy/</string>
<string>/Users/warren/.virtualenvs/keepuppy/bin/keepuppy_sync.py</string>
</array>
<key>Nice</key>
<integer>1</integer>
<key>StartInterval</key>
<integer>360</integer>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/keepuppy.log</string>
<key>StandardErrorPath</key>
<string>/tmp/keepuppy_error.log</string>
</dict>
</plist>
To run it as the desktop user when logged in, copy it to ~/Library/LaunchAgents/com.wamonite.keepuppy.plist
. To start it and
ensure it runs on reboot, use the following command:-
launchctl load ~/Library/LaunchAgents/com.wamonite.keepuppy.plist