If you are a more experienced Windows user, you might now the benefits of the ‘offline files and folders’ functionality. If you enable offline availability for a network share, then Windows is continuously holding a local copy of the content. You can take out the network cord and continue to work without any problem.
The Unix solution is two rsync (over ssh) calls in the right order, which allows you to sync your files with a directory on the remote file server machine. Let’s assume that you have directory “d” in your laptop home directory, and want to keep it synchronized it with directory “d” on a remote machine, regardless of where you changed something:
#!/bin/sh
rsync –progress -u -az -e ssh user@remotehost:/a/b/c/d ./
rsync –progress -u -az -e ssh ./d/ user@remotehost:/a/b/c/d
Naturally, deletions of files on both sides are not considered.
(BTW, because of this deletion sync problem, Windows simply does not allow deletions in offline mode.)
If you want to cleanup the directory, do it on the remote host stated above and execute the first rsync statement with an additional “–delete” option on the laptop. This deletes all files on the laptop that are not existent on the remote host.
Test this first with some unimportant data. You have been warned
…