mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-04-11 22:40:01 +03:00
wip
This commit is contained in:
parent
34d0c5d67b
commit
052890a7e0
113
zfs_autobackup
113
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user