From e6ac40283dbffa2ea5093a9cd2b563fd6add4fd0 Mon Sep 17 00:00:00 2001 From: Ted To Date: Tue, 13 Aug 2024 09:07:39 -0400 Subject: [PATCH] change to only do full backup on weekends --- management/backup.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/management/backup.py b/management/backup.py index aae6c00b..fafd5d6a 100755 --- a/management/backup.py +++ b/management/backup.py @@ -9,6 +9,7 @@ import os, os.path, re, datetime, sys import dateutil.parser, dateutil.relativedelta, dateutil.tz +from datetime import date import rtyaml from exclusiveprocess import Lock @@ -262,6 +263,9 @@ def get_target_type(config): def perform_backup(full_backup): env = load_environment() + # Check if day of week is a weekend day + weekend = date.today().weekday()>=5 + # Create an global exclusive lock so that the backup script # cannot be run more than one. Lock(die=True).forever() @@ -276,11 +280,11 @@ def perform_backup(full_backup): return # On the first run, always do a full backup. Incremental - # will fail. Otherwise do a full backup when the size of - # the increments since the most recent full backup are - # large. + # will fail. Otherwise do a full backup on weekends when + # the size of the increments since the most recent full + # backup are large. try: - full_backup = full_backup or should_force_full(config, env) + full_backup = (full_backup and weekend) or should_force_full(config, env) except Exception as e: # This was the first call to duplicity, and there might # be an error already.