3 # Storage hook for writing LBS backups directly to Amazon's Simple Storage
6 # Command-line arguments:
7 # <local_file> <type> <remote_name>
8 # Most options are controlled by environment variables:
9 # AWS_ACCESS_KEY_ID Amazon Web Services credentials
10 # AWS_SECRET_ACCESS_KEY " "
11 # LBS_S3_BUCKET S3 bucket in which data should be stored
12 # LBS_S3_PREFIX Path prefix to add to pathnames (include trailing
15 # This script depends upon the boto Python library for interacting with Amazon
20 from boto.s3.bucket import Bucket
21 from boto.s3.key import Key
23 prefix = os.environ.get('LBS_S3_PREFIX', "")
24 bucket_name = os.environ['LBS_S3_BUCKET']
25 (local_path, file_type, remote_path) = sys.argv[1:4]
27 conn = boto.connect_s3()
28 bucket = Bucket(conn, bucket_name)
30 k.key = prefix + file_type + "/" + remote_path
31 k.set_contents_from_filename(local_path)