Skip to content

Instantly share code, notes, and snippets.

@phpfunk
Last active December 24, 2015 10:39
Show Gist options
  • Save phpfunk/6786205 to your computer and use it in GitHub Desktop.
Save phpfunk/6786205 to your computer and use it in GitHub Desktop.
Really easy folder action to automatically backup any mobile photos that hit your Dropbox folder.

Really easy folder action to automatically backup any mobile photos that hit your Dropbox folder. You will have to change the data to your liking. All of my network/shared drives in the house are named after hip-hop groups or rappers.

NOTE: You must enable camera uploads for Dropbox and this was only tested and used on a Mac.

  • First you see I create a variable that is the current year and month, that way rsync will keep mobile photos saved in folders by YYYYMM.
  • Then I check if a network drive is already mounted, if not it gets mounted.
  • Next I cd to my DROPBOX Camera Uploads folder.
  • Then rsync to your heart's galore to as many drives as you wish.

In this example I sync to a network drive, then to a local external HDD, then after that remove the source files. This way after my photos are backed up they are removed from Dropbox and I can spare any space at Dropbox. I have this set up as a folder action for the folder set after cd. As soon as Dropbox hits that folder, it mounts the drives, syncs the images and removes the source files. Now everyone in my house doesn't have to worry about losing their mobile photos.

export FOLDER=`date +%Y%m`
if [ ! -d /Volumes/ChiddyBang ]; then
mkdir /Volumes/ChiddyBang
mount_afp afp://10.0.1.6/ChiddyBang /Volumes/ChiddyBang
fi
cd "/Users/phpfunk/Dropbox/Camera Uploads/"
rsync -arvu --exclude=".*" --include="*.jpg" --include="*.png" --include="*.mp4" * /Volumes/ChiddyBang/Photos/Phone\ Pics/$FOLDER/
rsync -arvu --remove-source-files --exclude=".*" --include="*.jpg" --include="*.png" --include="*.mp4" * /Volumes/WonderWhy/Photos/Phone\ Pics/$FOLDER/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment