From 052890a7e0aa10944d6a87948265093f82d2e83b Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Tue, 22 Oct 2019 21:59:01 +0200 Subject: [PATCH] wip --- zfs_autobackup | 113 ++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 68 deletions(-) diff --git a/zfs_autobackup b/zfs_autobackup index 92ad024..e1f8d48 100755 --- a/zfs_autobackup +++ b/zfs_autobackup @@ -200,49 +200,49 @@ class Thinner: -######### Thinner testing code -now=int(time.time()) - -t=Thinner("1d1w,1w1m,1m6m,1y2y", always_keep=1) - -import random - -class Thing: - def __init__(self, timestamp): - self.timestamp=timestamp - - def __str__(self): - age=now-self.timestamp - struct=time.localtime(self.timestamp) - return("{} ({} days old)".format(time.strftime("%Y-%m-%d %H:%M:%S",struct),int(age/(3600*24)))) - -def test(): - global now - things=[] - - while True: - print("#################### {}".format(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(now)))) - - (keeps, removes)=t.run(things, now) - - print ("### KEEP ") - for thing in keeps: - print(thing) - - print ("### REMOVE ") - for thing in removes: - print(thing) - - things=keeps - - #increase random amount of time and maybe add a thing - now=now+random.randint(0,160000) - if random.random()>=0: - things.append(Thing(now)) - - sys.stdin.readline() - -test() +# ######### Thinner testing code +# now=int(time.time()) +# +# t=Thinner("1d1w,1w1m,1m6m,1y2y", always_keep=1) +# +# import random +# +# class Thing: +# def __init__(self, timestamp): +# self.timestamp=timestamp +# +# def __str__(self): +# age=now-self.timestamp +# struct=time.localtime(self.timestamp) +# return("{} ({} days old)".format(time.strftime("%Y-%m-%d %H:%M:%S",struct),int(age/(3600*24)))) +# +# def test(): +# global now +# things=[] +# +# while True: +# print("#################### {}".format(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(now)))) +# +# (keeps, removes)=t.run(things, now) +# +# print ("### KEEP ") +# for thing in keeps: +# print(thing) +# +# print ("### REMOVE ") +# for thing in removes: +# print(thing) +# +# things=keeps +# +# #increase random amount of time and maybe add a thing +# now=now+random.randint(0,160000) +# if random.random()>=0: +# things.append(Thing(now)) +# +# sys.stdin.readline() +# +# test() @@ -1004,28 +1004,5 @@ class ZfsAutobackup: raise -#times=[] - - - - - -# -# test() -# -# -# -# -# -# -# -# -# now=time.time() -# time_str=re.findall("^.*-([0-9]*)$", snapshot)[0] -# if len(time_str)==14: -# #new format: -# time_secs=time.mktime(time.strptime(time_str,"%Y%m%d%H%M%S")) -# -# -# zfs_autobackup=ZfsAutobackup() -# zfs_autobackup.run() +zfs_autobackup=ZfsAutobackup() +zfs_autobackup.run()