Share the Knowledge!

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

/Users/ian/Dropbox/MySharedFolder

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:

./shadow -all

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:

./unshadow -all

this form removes completely all shadow information, copies and the background process.

./unshadow /full-absolute-path-to-a-dropbox-share

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:

/Users/ian/Dropbox

shadow creates

/Users/ian/not-Dropbox

Then, if you shadow /Users/ian/Dropbox/MySharedFolder, it will create:

/Users/ian/not-Dropbox/MySharedFolder

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.)

Support

You can email me at shadow@cottamgoble.co.uk. 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.

Thanks

Andrew Scheller provided the function get_dropbox_folder. Many thanks!

Share the Knowledge!

Helpful(0) Unhelpful(0)
  • Ian Cottam

    This version 0.3 breaks with the latest version of Dropbox.
    Email me for version 0.4 which has the fix. shadow@cottamgoble.co.uk
    Note: you don’t need this little app if you have Dropbox for Business and 0.4 will refuse to run.

    • Dropbox Wiki

      Hi Ian, thanks for providing an update. Is there any way to get version 0.4 updated on this site?