Backing Up Your Mobile Data with AWS Dropbox Automation

Backing Up Your Mobile Data

It's been about 15 years since the first camera phones came out, but now everyone has one and they take lots of pictures. Do you have a back up strategy for all of those pictures and videos? In this post I'll show you how to use Aws together with Dropbox to automatically backup all of your mobile data with very little effort and money.

The Plan ...

Before getting started here you'll need an Aws account and Dropbox account. I'm going to show you how to install Dropbox on a Linux ec2 instance and activate the Dropbox Deaemon. If you then put the Dropbox app on your phone the ec2 instance will have access to all your photos. That much alone already accomplishes automated, encrypted backup. The only issues is you'll end up having to pay for Dropbox after you dump enough files in there. Dropbox generously has a free 2 gig account so you can run a cron job to move your files from Dropbox to S3. It's true you'll have to pay for S3 usage, but it's cheap. You can make it cheaper by using life cycle polices on your bucket and promoting your media to Amazon Glacier. This strategy gives you cheap persistent storage and frees you from ever worrying about losing your phone or every hooking it up to a computer ever again.

Dropbox on Linux

Dropbox is a very stable product and installing it on Linux is pretty simple. At this point we're assuming you have a Linux ec2 instance up and running and have made a dedicated Dropbox bucket to store your phones media in. To follow this guide be sure to give you instance the S3 full access role. For this experiment I used an Ubuntu instance. To install Dropbox all you need to do is run the command.
cd ~ && wget -O - "" | tar xzf -

Now you can use the command ~/.dropbox-dist/dropboxd to start the Dropbox daemon. This will return an url for you to follow in your browser. Once you hit the endpoint and login to your Dropbox account you will have associated the ec2 instance to your account. When done correctly you'll see

Now you can use the Dropbox provided Python script to start the Dropbox Client. You can download it here. Once you have copied over the Python script you can use the command python start to start synchronization. Once Dropbox is fully activated and ready to sync your files it will look like this

It's worth noting at this point that you can check your Dropbox run status with the aforementioned Python Script. For example python status will tell if you the daemon is running or has stopped. The command python help will give even more options. If you ever snapshot the EBS volume for this instance it's important that you'll need to restart the daemon manually. Once Dropbox is successfully installed it will add the directory structure Dropbox/Camera\ Uploads/. This is the directory where Dropbox will sync your mobile files. I want to move all the data to a bucket for easy access and storage. To accomplish that I wrote a small script using the Aws command line interface to move the files over to S3. I'm calling my script s3sync and it looks like this.

aws s3 mv Dropbox/Camera\ Uploads/  s3://dropboxBucket --recursive  

Be sure to change the permissions of the script to make it executable by using something of the form chmod 755 s3sync Now it's easy to call that script daily from the crontab. To edit your cron jobs use the command crontab -e and add the line @hourly cd /home/ubuntu/ && ./s3sync. Now when you take a picture on your phone it goes into Dropbox via the app and your ec2 instance will fire your S3 migration script hourly to keep you within the free limits of Dropbox.

Do Your Really Need S3 ?

The short answer to that question is no. However, S3 does give you the most flexibility and transparency as to where your files actually go. In reality, you could just move the Dropbox files to a directory on the local instance and then snapshot the root EBS volume. You can even automate that snapshot via CloudWatch. The snapshot is stored in the same storage class as S3 so you get the same availability and durability as S3.

Time to go PhotoCrazy

There are other backup strategies that differ from what I have given here, but there is tremendous peace of mind having a strategy in place. I know that people will say they use Amazon Prime to store their photos or icloud does it automatically. I only see this and them holding your data hostage for further payment.