User Tools

Site Tools


db-sync

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
db-sync [2023/04/25 15:56] stevedb-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't
 +# 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=/Scratch/Database.kdbx File1=/Scratch/Database.kdbx
 File2=/home/steve/.Nextcloud/LCS_Stuff/Database.kdbx File2=/home/steve/.Nextcloud/LCS_Stuff/Database.kdbx
 +
 +# 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} /home/steve/.Nextcloud/LCS_Stuff/ \     rsync -a ${File1} /home/steve/.Nextcloud/LCS_Stuff/ \
     || exit 0     || exit 0
 </code> </code>
db-sync.1682438212.txt.gz · Last modified: by steve