mirror of
https://github.com/borgbackup/borg.git
synced 2026-03-18 16:43:42 -04:00
Sort archive listing in chronological order
This commit is contained in:
parent
731af5414a
commit
0629afc2dd
3 changed files with 14 additions and 4 deletions
|
|
@ -43,6 +43,11 @@ class Archive(object):
|
|||
self.metadata = msgpack.unpackb(data)
|
||||
assert self.metadata['version'] == 1
|
||||
|
||||
@property
|
||||
def ts(self):
|
||||
"""Timestamp of archive creation in UTC"""
|
||||
return datetime.strptime(self.metadata['time'], '%Y-%m-%dT%H:%M:%S.%f')
|
||||
|
||||
def get_chunks(self):
|
||||
for id in self.metadata['chunks_ids']:
|
||||
magic, data, hash = self.keychain.decrypt(self.store.get(NS_ARCHIVE_CHUNKS, id))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import argparse
|
||||
from datetime import datetime
|
||||
from operator import attrgetter
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
|
|
@ -9,7 +10,7 @@ from .store import Store
|
|||
from .cache import Cache
|
||||
from .keychain import Keychain
|
||||
from .helpers import location_validator, format_file_size, format_time,\
|
||||
format_file_mode, IncludePattern, ExcludePattern, exclude_path
|
||||
format_file_mode, IncludePattern, ExcludePattern, exclude_path, to_localtime
|
||||
from .remote import StoreServer, RemoteStore
|
||||
|
||||
class Archiver(object):
|
||||
|
|
@ -152,8 +153,8 @@ class Archiver(object):
|
|||
print '%s%s %-6s %-6s %8d %s %s' % (type, mode, item['user'],
|
||||
item['group'], size, mtime, item['path'])
|
||||
else:
|
||||
for archive in Archive.list_archives(store, keychain):
|
||||
print '%(name)-20s %(time)s' % archive.metadata
|
||||
for archive in sorted(Archive.list_archives(store, keychain), key=attrgetter('ts')):
|
||||
print '%-20s %s' % (archive.metadata['name'], to_localtime(archive.ts).strftime('%c'))
|
||||
return self.exit_code
|
||||
|
||||
def do_verify(self, args):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import argparse
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from fnmatch import fnmatchcase
|
||||
import grp
|
||||
import os
|
||||
|
|
@ -7,7 +7,11 @@ import pwd
|
|||
import re
|
||||
import stat
|
||||
import struct
|
||||
import time
|
||||
|
||||
def to_localtime(ts):
|
||||
"""Convert datetime object from UTC to local time zone"""
|
||||
return ts - timedelta(seconds=time.altzone)
|
||||
|
||||
def read_set(path):
|
||||
"""Read set from disk (as int32s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue