Shadow is a simple Mac OS X Bash script to set up shadow (or mirror) copies of any of your Dropbox shared folders. If a collaborator or user of the share deletes files by, for example, dragging them out of the share, shadow puts them back.
WARNING!!! The current version (v0.3) does not put back extended attributes and any resource fork. If such is important to you, please do not use this version. Please visit this forum topic for more details and a discussion of how this may change in the next version of Shadow.
Any user of the share can still add files and folders and even modify files. There is no attempt to avoid conflicted copies, which can still occur in the usual way. The user of shadow should not change the name of shadowed/shared folders.
Installation and Usage
Just download the script and store it anywhere you like. It is probably best to be on your $PATH somewhere, but that is not necessary. You could just drag it from where it downloaded to the top-level of your user file store. Below I will assume it is in the current working directory and run it via the relative path ./shadow.
Make it executable via:
chmod +x ./shadow
in a Terminal window. You also need to give it the name unshadow via:
ln -s shadow unshadow
To use shadow:
./shadow /full-absolute-path-to-a dropbox-share . . .
the . . . just means you can give multiple arguments, one for each share you wish shadowed. You don’t need the ./ in front of shadow if it is in a directory on your $PATH. Note that you need to give full pathname arguments to shadow, such as
rather than a relative path.
If shadow detects that the folder is within the user’s dropbox but is not currently shared, it produces a warning for information, but still starts the shadowing process. Thus, it does not matter if you use Dropbox to create a share and then invoke shadow or the other way around. Shadow does not currently check that you have asked (wrongly) to shadow sub-folders of shared/shadowed folders. [Likely fixed in next version.] Obviously, if you do the Dropbox share attempt first, Dropbox will stop you attempting to share sub-folders of shares. Contrariwise, if you do the shadow first, you can be confident that no one has dragged anything out of the share before shadow starts working.
Only the owner of the share should run shadow, although that cannot be enforced. If the owner is not a Mac user but a collaborator is, it is fine for the collaborator to run shadow (with the share owner’s knowledge of course).
From version 0.3 (9th December 2011) of shadow, there is also the option to run as:
This detects all your currently shared folders (they contain a .dropbox file) and shadows them. Exercise caution with this option. For example, I have over 12GB of shared folders. You both need the space to shadow and the setup will take quite some time to do the initial sync from the Dropbox folders to the not-Dropbox ones. You can monitor this initial setup by right-clicking on the not-Dropbox folder and selecting Get Info. You should see the folder growing in size. Another reason to exercise caution is that shadow cannot tell which shares are owned by you and which are owned by others; hence, it will shadow both sets.
There are two ways to use unshadow:
this form removes completely all shadow information, copies and the background process.
this form just stops shadowing the supplied share. It does not delete the shadow folder.
How it works
For each folder you shadow the script creates a copy outside of Dropbox in a parallel folder structure. That is, say your dropbox is here:
Then, if you shadow /Users/ian/Dropbox/MySharedFolder, it will create:
Every couple of minutes a background process runs rsync, in both directions, to save and restore any changes. The background process is controlled via the Mac standard: launchctl / launchd. (Thanks to Andrew Scheller the next release –coming soon– will also work on Linux. I can’t help with Windows, other than to say robocopy could be used for rsync.)
You can email me at email@example.com. Shadow has been tested on Lion, but may well work on less recent versions of OS X provided they support launchctl/launchd.
Warnings and Disclaimers
Donated to the public domain. No warranties of any kind.
Andrew Scheller provided the function get_dropbox_folder. Many thanks!