Skip to content

Commit

Permalink
backups will now fail with a sensible error if no profiles are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
staircase27 committed Nov 28, 2016
1 parent 33600fc commit 54fde57
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/backups/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def applydelta(timestamp,amount,unit):

def doschedule(config,now,backups):
schedule=config["schedule"]
if len(schedule)<=0:
raise BackupError("No schedule defined.")
for tag,maxage,ageunit in schedule:
if tag not in backups or backups[tag][-1][1]<applydelta(now,-maxage,ageunit):
return tag
Expand All @@ -112,7 +114,6 @@ def backup(dir,config,profile=None):
for key,val in backups.items():
val.sort(key=lambda ft: ft[1])


if profile==None:
profile=doschedule(config,now,backups)
data=getprofiledata(config,profile)
Expand Down Expand Up @@ -154,7 +155,7 @@ def checkdatavalue(data,key,*value):
return "DELETE"
else:
return list(value)
elif key[2] in ("replace_targets","replace_exlclusions"):
elif key[2] in ("replace_targets","replace_exclusions"):
if len(value) != 1:
raise BackupError("key only takes one value")
if value[0].lower() in ("t","y","true","yes","on"):
Expand Down

0 comments on commit 54fde57

Please sign in to comment.