From 389203735101f7b42b6498a082d513589c45c8b7 Mon Sep 17 00:00:00 2001 From: Ryan Tucker Date: Wed, 21 Sep 2011 20:39:15 -0400 Subject: [PATCH] Use SSL to talk to S3, and tweak send_file Note: We're now dependent upon Boto 2.0. --- BackupPC_archiveHost_s3 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/BackupPC_archiveHost_s3 b/BackupPC_archiveHost_s3 index 83ee3c7..54de70e 100755 --- a/BackupPC_archiveHost_s3 +++ b/BackupPC_archiveHost_s3 @@ -83,7 +83,7 @@ def encrypt_file(filename, key, compress='/bin/cat'): raise Exception def open_s3(accesskey, sharedkey, host): - conn = S3Connection(accesskey, sharedkey, is_secure=False) + conn = S3Connection(accesskey, sharedkey, is_secure=True) mybucketname = (accesskey + '-bkup-' + host).lower() try: bucket = conn.get_bucket(mybucketname) @@ -98,14 +98,14 @@ def handle_progress(transmitted, pending): def send_file(bucket, filename): basefilename = os.path.basename(filename) - if bucket.get_key(basefilename): - logger.error('Duplicate filename %s! I hope that is OK.' % basefilename) + logger.info('Uploading %s...' % basefilename) + k = Key(bucket) k.key = basefilename - logger.info('Uploading %s...' % basefilename) - fd = open(name=filename, mode='rb') - putHeaders = {'x-amz-storage-class': 'REDUCED_REDUNDANCY'} - k.set_contents_from_file(fd, headers=putHeaders, cb=handle_progress) + if k.exists(): + logger.warning('Duplicate filename %s! I hope that is OK.' % basefilename) + k.set_contents_from_filename(filename, cb=handle_progress, reduced_redundancy=True) + return k def encryption_worker(in_q, out_q):