more accurate backup age handling; also nuking the .COMPLETE file on a delete
This commit is contained in:
parent
9edeab8662
commit
1fea10bc03
1 changed files with 12 additions and 4 deletions
|
@ -71,12 +71,15 @@ def list_backups(bucket):
|
||||||
|
|
||||||
if hostname in backups.keys():
|
if hostname in backups.keys():
|
||||||
if not backupnum in backups[hostname].keys():
|
if not backupnum in backups[hostname].keys():
|
||||||
backups[hostname][backupnum] = {'date': lastmod, 'hostname': hostname, 'backupnum': backupnum, 'finalized': 0, 'keys': []}
|
backups[hostname][backupnum] = {'date': lastmod, 'hostname': hostname, 'backupnum': backupnum, 'finalized': 0, 'keys': [], 'finalkey': None}
|
||||||
else:
|
else:
|
||||||
backups[hostname] = {backupnum: {'date': lastmod, 'hostname': hostname, 'backupnum': backupnum, 'finalized': 0, 'keys': []}}
|
backups[hostname] = {backupnum: {'date': lastmod, 'hostname': hostname, 'backupnum': backupnum, 'finalized': 0, 'keys': [], 'finalkey': None}}
|
||||||
if final:
|
if final:
|
||||||
backups[hostname][backupnum]['finalized'] = lastmod
|
backups[hostname][backupnum]['finalized'] = lastmod
|
||||||
|
backups[hostname][backupnum]['finalkey'] = key
|
||||||
else:
|
else:
|
||||||
|
if lastmod < backups[hostname][backupnum]['date']:
|
||||||
|
backups[hostname][backupnum]['date'] = lastmod
|
||||||
backups[hostname][backupnum]['keys'].append(key)
|
backups[hostname][backupnum]['keys'].append(key)
|
||||||
return backups
|
return backups
|
||||||
|
|
||||||
|
@ -234,11 +237,10 @@ def main():
|
||||||
backups = hostnames[hostname]
|
backups = hostnames[hostname]
|
||||||
for backupnum in backups.keys():
|
for backupnum in backups.keys():
|
||||||
filecount = len(backups[backupnum]['keys'])
|
filecount = len(backups[backupnum]['keys'])
|
||||||
|
datestruct = backups[backupnum]['date']
|
||||||
if backups[backupnum]['finalized'] > 0:
|
if backups[backupnum]['finalized'] > 0:
|
||||||
datestruct = backups[backupnum]['finalized']
|
|
||||||
inprogress = ''
|
inprogress = ''
|
||||||
else:
|
else:
|
||||||
datestruct = backups[backupnum]['date']
|
|
||||||
inprogress = '*'
|
inprogress = '*'
|
||||||
timestamp = time.mktime(datestruct)
|
timestamp = time.mktime(datestruct)
|
||||||
delta = int(time.time() - timestamp + time.timezone)
|
delta = int(time.time() - timestamp + time.timezone)
|
||||||
|
@ -282,6 +284,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
key.delete()
|
key.delete()
|
||||||
sys.stdout.write('.')
|
sys.stdout.write('.')
|
||||||
|
if backups[backupnum]['finalkey']:
|
||||||
|
backups[backupnum]['finalkey'].delete()
|
||||||
|
sys.stdout.write('!')
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
elif options.host and options.backupnum:
|
elif options.host and options.backupnum:
|
||||||
for bucket in buckets:
|
for bucket in buckets:
|
||||||
|
@ -310,6 +315,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
key.delete()
|
key.delete()
|
||||||
sys.stdout.write('.')
|
sys.stdout.write('.')
|
||||||
|
if backups[backupnum]['finalkey']:
|
||||||
|
backups[backupnum]['finalkey'].delete()
|
||||||
|
sys.stdout.write('!')
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
else:
|
else:
|
||||||
parser.error('Host %s not found' % options.host)
|
parser.error('Host %s not found' % options.host)
|
||||||
|
|
Loading…
Reference in a new issue