I am looking for alternative options that others may be doing for the above topic.
I really learned to appreciate the “off-line files” option that worked fairly well under Windows. How to simulate something like that so mobile users can have access to files that they might normally access via a share (as I do with Samba on my Debian server). But I also wanted something that would poll for added/deleted/moved/changed files PLUS this needed to be monitored recursively.
So - here’s what I come up with (Standard disclaimer: I am not a coder nor do I play one in real life, so do not go into code-shock when you view possible hideous syntax)
I installed inotified-tools that included inotifywait (mind you, the key I needed was recursiveness)
The following is a script (I called dsync.sh) I threw together
#!/bin/bash while inotifywait -r -e create -e delete -e modify -e moved_from -e moved_to /home/chris/Documents; do notify-send "Documents have been changed..."; sleep 30; rsync -avze ssh /home/chris/Documents/ chris@moodaddy:/media/Data/Users/chris/; notify-send "Synchronising documents..."; done
Before running the script against my /home/chris/Documents dir, I needed to create a key so that I would not be prompted for the SSH password then copy that info to the Debian server.
I’m leaving some of the bits out simply because I know that most of you know what to be done
The “sleep” I included (and can be varied) to allow for additional changes if needed. If I would be working with many files, I could simply expand that 30 seconds to nearly infinity if need be. The reason for this; so that syncing does not happen instantly/or multiple times etc.
Moving on, I commented out my access to the samba share that I had within /etc/fstab, unmounted /home/chris/Documents then copied the data from the server to my laptop.
Chmod +x dsync.sh and added into a directory that is within my path (/home/chris/bin was an obvious choice). Removed the files from the server within Users/chris (don’t panic, the server has a 2nd drive while not mirrored, does get rsync’d each night).
Add this line to my /home/chris/.xprofile (opted for full path for redundancy):
/home/chris/bin/dsync.sh > /dev/null 2>&1 &
Rebooted then tested this simply doing touch moo.txt in the /home/chris/Documents directory.
After the creation of said file, I nice message came over (dunst of course) that told me files had been changed. 30 seconds later, another nice message popped up and let me know that the sync completed.
Low and behold while testing the above, I did indeed see the file being synced to the server then removed.
One thing I didn’t mention, it did take a bit of time to have the files re-replicate to the server. I suppose I could have just left them, but the first sync still would have taken a good bit of time.
So I guess the question is; are you doing some form of off-line file syncing?
I would love to see what others might be doing.