plan c for writing metadata
This commit is contained in:
parent
d1256d08cc
commit
db7cea8a7e
1 changed files with 5 additions and 5 deletions
|
@ -204,12 +204,14 @@ def open_s3(accesskey, sharedkey, host):
|
||||||
def handle_progress(transmitted, pending):
|
def handle_progress(transmitted, pending):
|
||||||
logging.debug('%i of %i bytes transmitted (%.2f%%)' % (transmitted, pending, (transmitted/float(pending))*100))
|
logging.debug('%i of %i bytes transmitted (%.2f%%)' % (transmitted, pending, (transmitted/float(pending))*100))
|
||||||
|
|
||||||
def send_file(bucket, filename):
|
def send_file(bucket, filename, cmd, mesg):
|
||||||
basefilename = os.path.basename(filename)
|
basefilename = os.path.basename(filename)
|
||||||
if bucket.get_key(basefilename):
|
if bucket.get_key(basefilename):
|
||||||
logging.error('Duplicate filename %s! I hope that is OK.' % basefilename)
|
logging.error('Duplicate filename %s! I hope that is OK.' % basefilename)
|
||||||
k = MyKey(bucket)
|
k = MyKey(bucket)
|
||||||
k.key = basefilename
|
k.key = basefilename
|
||||||
|
if cmd: k.set_metadata('backuppc_cmd', cmd)
|
||||||
|
if mesg: k.set_metadata('backuppc_mesg', mesg)
|
||||||
logging.info('Uploading %s...' % basefilename)
|
logging.info('Uploading %s...' % basefilename)
|
||||||
|
|
||||||
fd = SlowFile(name=filename, mode='rb')
|
fd = SlowFile(name=filename, mode='rb')
|
||||||
|
@ -303,11 +305,8 @@ for i in sorted(glob.glob(fileglob)):
|
||||||
|
|
||||||
while retry_count <= max_retries:
|
while retry_count <= max_retries:
|
||||||
try:
|
try:
|
||||||
key = send_file(bucket, sendfile)
|
key = send_file(bucket, sendfile, cmd, mesg)
|
||||||
key.set_metadata('backuppc_cmd', cmd)
|
|
||||||
key.set_metadata('backuppc_mesg', mesg)
|
|
||||||
key.set_acl('private')
|
key.set_acl('private')
|
||||||
key.update_metadata()
|
|
||||||
key.close()
|
key.close()
|
||||||
retry_count = max_retries+1
|
retry_count = max_retries+1
|
||||||
except boto.exception.S3ResponseError as e:
|
except boto.exception.S3ResponseError as e:
|
||||||
|
@ -325,6 +324,7 @@ for i in sorted(glob.glob(fileglob)):
|
||||||
bytespersecond = size / (sending_seconds - encrypt_seconds)
|
bytespersecond = size / (sending_seconds - encrypt_seconds)
|
||||||
|
|
||||||
sys.stdout.write('%s: File sent. Total time %i seconds, crypto time %i seconds, transfer speed %i bytes/second.\n' % (time.strftime('%d-%H:%M:%S'), sending_seconds, encrypt_seconds, bytespersecond))
|
sys.stdout.write('%s: File sent. Total time %i seconds, crypto time %i seconds, transfer speed %i bytes/second.\n' % (time.strftime('%d-%H:%M:%S'), sending_seconds, encrypt_seconds, bytespersecond))
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
# finalize the backup
|
# finalize the backup
|
||||||
key = MyKey(bucket)
|
key = MyKey(bucket)
|
||||||
|
|
Loading…
Reference in a new issue