Mount an Amazon S3 bit bucket as a drive in unix using FUSE

 - by Asher Bond

You can put this in your startup scripts, but I just run mine when I want to upload files to S3 for content distribution or for backup. A couple of my backup scripts invoke this script, then umount fuse when they’re done backing things up to s3. It hasn’t fully been tested yet, but let me know how it works out. Remember to store your AWS credentials in a safe place where only trusted people can read them. It’s also a good idea to expire and rotate them frequently.

#!/bin/bash
# Asher Bond 2010
# http://www.asherbond.com/blog/2010/09/14/mount-an-amazon-s3-bit-bucket-as-a-drive-in-unix-using-fuse/
#
# USAGE: s3-mount.sh bucket-name [/mnt/point/optional/if/different]
#
# mount s3 using s3-simple-fuse
# This is released under GPL
# you might need to:
# See http://code.google.com/p/s3-simple-fuse/ for s3-simple-fuse
# apt-get install python-fuse
# apt-get install python-dateutil
# apt-get install python-boto

# if you don't specify a mount point it just assumes /mnt/bit-bucket-name
function s3-mount ()
{

        if [ "$#" == 1 ] ; then
                # allow for custom /mnt/points
                mnt="/mnt/$1"
        else    mnt="$2"
        fi

        # keep this safe
        aws_access_key_id='AKUIAS7YOURMOM8XUTA4GA'
        aws_secret_access_key='sa09idontask2hsdfkjh34tnotrealna5p8'

        mkdir $mnt
        s3-simple-fuse $mnt -o AWS_ACCESS_KEY_ID=$aws_access_key_id,AWS_SECRET_ACCESS_KEY=$aws_secret_access_key,bucket=$1

}

s3-mount $1 $2

# to-do: mount google storage
# http://code.google.com/apis/storage/
#function google-storage-mount ()
#{
#}
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • NewsVine
  • PDF
  • Reddit
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Twitter
  • eKudos
  • FriendFeed
  • Google Buzz
  • RSS
  • Tumblr

Leave a comment