User Tools

Site Tools


db-sync

DB-Sync

In this case, /Scratch is a folder mapped by VirtualBox

DB-Sync
#!/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
File2=/home/steve/.Nextcloud/LCS_Stuff/Database.kdbx
 
# No Windows DB, we're outa here. 
[ ! -f ${File1} ] && exit 2
 
# No NextCloud DB, also run
[ ! -f ${File2} ] && exit 3
 
# If Windows DB is newer than (-nt) NC DB, run rsync, otherwise, exit with zero errorlevel
[ ${File1} -nt ${File2} ] && \
    rsync -a ${File1} /home/steve/.Nextcloud/LCS_Stuff/ \
    || exit 0
db-sync.txt · Last modified: by steve