示例#1
0
def main(argv):
    if "-h" in argv:
        print "./simulate.py [backup-timestamps]"
        return 1

    # Do some default simulation
    if not argv:
        s = BackupSimulator(parse_deltas("1d 7d 30d"))

        until = s.now + timedelta(days=17)
        while s.now <= until:
            s.go_by(timedelta(days=1))
            s.backup()

        for name, date in s.backups.iteritems():
            print name

    # Simulate a backup with the timestamps given
    else:
        s = BackupSimulator(parse_deltas("1d 7d 30d"))
        s.add([d for d in argv])
        deleted, _ = s.expire()

        print "Deleted backups:"
        for name in deleted:
            print (name)

        print ""
        print "Remaining backups:"
        for name, date in s.backups.iteritems():
            print name
示例#2
0
def test_failing_keep():
    """This used to delete backup B, because we were first looking
    for a seven day old backup, finding A, then looking for a six day
    old backup, finding A again (it is closer to six days old then B)
    and then stopping the search, assuming after two identical matches
    that there are no more.
    """
    s = BackupSimulator('1d 7d')
    s.add([
        '20100615-000000',   # A
        '20100619-000000',   # B
        '20100620-000000',   # C
    ])
    delete, keep = s.expire()
    assert not delete
示例#3
0
def test_failing_keep():
    """This used to delete backup B, because we were first looking
    for a seven day old backup, finding A, then looking for a six day
    old backup, finding A again (it is closer to six days old then B)
    and then stopping the search, assuming after two identical matches
    that there are no more.
    """
    s = BackupSimulator('1d 7d')
    s.add([
        '20100615-000000',  # A
        '20100619-000000',  # B
        '20100620-000000',  # C
    ])
    delete, keep = s.expire()
    assert not delete
示例#4
0
def main(argv):
    s = BackupSimulator(parse_deltas('1d 7d 30d'))

    until = s.now + timedelta(days=17)
    while s.now <= until:
        s.go_by(timedelta(days=1))
        s.backup()

    for name, date in s.backups.iteritems():
        print name
示例#5
0
def main(argv):
    if '-h' in argv:
        print "./simulate.py [backup-timestamps]"
        return 1

    # Do some default simulation
    if not argv:
        s = BackupSimulator(parse_deltas('1d 7d 30d'))

        until = s.now + timedelta(days=17)
        while s.now <= until:
            s.go_by(timedelta(days=1))
            s.backup()

        for name, date in s.backups.iteritems():
            print name

    # Simulate a backup with the timestamps given
    else:
        s = BackupSimulator(parse_deltas('1d 7d 30d'))
        s.add([d for d in argv])
        deleted, _ = s.expire()

        print "Deleted backups:"
        for name in deleted:
            print(name)

        print ""
        print "Remaining backups:"
        for name, date in s.backups.iteritems():
            print name