Backup images or almost anything from iPhone (any iOS) to Amazon S3

December 16, 2011 by  
Filed under hack$, iPhone, Linux, News, Uncategorized

This guide is for jailbroken iPhone/iPod touch only
I had recently needed a quick and dirty way to backup some of my images and additional content from my jailbroken iPhone 4 to a safe and accessible location. Well, you could always backup through iTunes (or any other USB/WiFi/Bluetooth means available), but being in love with the Amazon web services I decided to utilize some available tools and backup/sync to the Amazon S3.

In order to do so, I had decided to use one of my favorite FREE tools s3cmd from s3tools.

S3cmd is a command line tool for uploading, retrieving and managing data in Amazon S3. It is best suited for power users who don’t fear command line. It is also ideal for scripts, automated backups triggered from cron, etc.”

There are a few prerequisites in order to get this running. You will need the following:

  • Amazon account ( I will not get into details on how to create one, but if interested let me know and I’ll post a detail step-by-step)
  • WiFi connection
  • Computer (Mac/PC/and Linux flavor with command line)
  • SSH Access to iPhone
  • Wget package from Cydia
  • Python from Cydia
  • s3cmd tools from s3tools

So, here’s what worked for me:

The final goal was to be able to create a bucket on S3 and upload/sync some content directly to the new S3 bucket.

    1. Enable SSH access to the iPhone: On your iPhone go to Cydia and search for OpenSSH and install it.

Download OpenSSH on iPhone - Cydia

    1. Still in Cydia, search for wget and install it as well.

Install wget on iPhone - Cydia

    1. Search for Python on Cydia and install that package too.

Install Python on iPhone - Cydia

Now we have the necessary tools on the iDevice and could continue easier from the computer.

    1. Go to your computer and fire up your terminal (Putty on your Win PC).
    2. Find out the iDevice’s IP address and ssh as root into it.

On your device go to: Settings->WiFi. Click on the blue arrow on the selected WiFi network and memorize your IP address. Mine at this time is:

SSH as root (your IP will be most likely different):

The default root password for the iOS is: alpine . At that point you will be at:

    1. You now need to download s3cmd by using wget:
    1. Unarchive the downloaded software:
tar -zxvf s3cmd-1.0.1.tar.gz

Remove the downloaded archive and rename the new folder:

rm s3cmd-1.0.1.tar.gz
mv s3cmd-1.0.1/ s3cmd
    1. Move into the new folder and fireup s3cmd. First thing we need to do is associate the tool with your existing Amazon S3 credentials:
./s3cmd --configure
Access key and Secret key are your identifiers for Amazon S3
Access Key: YouRAcceSSkEy
Secret Key: YourVeryLoNGSecrEtKey
Encryption password: YourGreatPassw0rd
Path to GPG program [/usr/bin/gpg]: leave empty
Use HTTPS protocol [No]:
HTTP Proxy server name: leave empty
New settings:
Access Key: YouRAcceSSkEy
Secret Key: YourVeryLoNGSecrEtKey+8A0Cs
Encryption password: YourGreatPassw0rd
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: False
HTTP Proxy server name:
HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n]

Type Y and hit enter to save the configuration. We are now ready to create our bucket on S3 and end some files there.

  1. Create an S3 bucket
./s3cmd mb s3://my-new-S3-bucket
Bucket 's3://my-new-S3-bucket/' created

Now I’m ready to upload some images to my new S3 bucket. The images on my iPhone are located at:


Now I can upload the entire folder to S3:

./s3cmd put --acl-private --guess-mime-type --recursive /var/mobile/Media/DCIM/100APPLE s3://my-new-S3-bucket

The command above will recursively –recursive upload the entire folder to S3, it will automatically set the mime type –guess-mime-type and it will set all files to private –acl-private. If I was to set the flag to –acl-public, all of the images would become public and accessible through http/https.

In order to sync the folder, s3cmd has that option as well which is similar to the Unix rsync:

./s3cmd sync --dry-run --skip-existing --delete-removed /var/mobile/Media/DCIM/101APPLE s3://my-new-S3-bucket
upload: /var/mobile/Media/DCIM/101APPLE/IMG_1002.JPG -> s3://my-new-S3-bucket/101APPLE/IMG_1002.JPG
upload: /var/mobile/Media/DCIM/101APPLE/IMG_1003.JPG -> s3://my-new-S3-bucket/101APPLE/IMG_1003.JPG
upload: /var/mobile/Media/DCIM/101APPLE/IMG_1007.JPG -> s3://my-new-S3-bucket/101APPLE/IMG_1007.JPG
WARNING: Exitting now because of --dry-run

I had used –dry-run to check what will get synced before I run it.

Please feel free to ask any questions. I will follow with automating this and adding it to the Springboard.