db-sync
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| db-sync [2023/04/25 15:56] – steve | db-sync [2023/04/25 16:45] (current) – steve | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| <code bash DB-Sync> | <code bash DB-Sync> | ||
| #!/bin/bash | #!/bin/bash | ||
| + | # This syncs my KeePass database between a Windows PC that I probably shouldn' | ||
| + | # run the NextCloud Client on, with home - I'm allowed to run VirtualBox, with | ||
| + | # a Mint client that is set up to auto-map the /Scratch folder on the C:\ drive. | ||
| + | # File1 is the Windows version of the database, and changes pretty often | ||
| + | # File2 is the version at home, this script runs (via cron) once an hour, checks | ||
| + | # to see if there has been a change, and runs rsync if there has been. | ||
| + | |||
| File1=/ | File1=/ | ||
| File2=/ | File2=/ | ||
| + | |||
| + | # No Windows DB, we're outa here. | ||
| [ ! -f ${File1} ] && exit 2 | [ ! -f ${File1} ] && exit 2 | ||
| + | |||
| + | # No NextCloud DB, also run | ||
| [ ! -f ${File2} ] && exit 3 | [ ! -f ${File2} ] && exit 3 | ||
| + | |||
| + | # If Windows DB is newer than (-nt) NC DB, run rsync, otherwise, exit with zero errorlevel | ||
| [ ${File1} -nt ${File2} ] && \ | [ ${File1} -nt ${File2} ] && \ | ||
| rsync -a ${File1} / | rsync -a ${File1} / | ||
| || exit 0 | || exit 0 | ||
| </ | </ | ||
db-sync.1682438212.txt.gz · Last modified: by steve
