Convert minimum_backup_age to minutes

This commit is contained in:
Orsiris de Jong 2023-02-02 10:58:09 +01:00
parent 00c30c1731
commit 6ab6ed9ef3
6 changed files with 13 additions and 13 deletions

View file

@ -49,7 +49,7 @@ empty_config_dict = {
"exclude_caches": True,
"priority": "low",
},
"repo": {"minimum_backup_age": 86400},
"repo": {"minimum_backup_age": 1440},
"prometheus": {},
"env": {},
"options": {},

View file

@ -293,7 +293,7 @@ class NPBackupRunner:
self.config_dict["repo"]["minimum_backup_age"]
)
except (KeyError, ValueError):
self.minimum_backup_age = 86400
self.minimum_backup_age = 1440
self.restic_runner.verbose = self.verbose
self.restic_runner.dry_run = self.dry_run
@ -326,7 +326,7 @@ class NPBackupRunner:
def check_recent_backups(self) -> bool:
logger.info(
"Searching for a backup newer than {} ago.".format(
str(datetime.timedelta(seconds=self.minimum_backup_age))
str(datetime.timedelta(minutes=self.minimum_backup_age))
)
)
result = self.restic_runner.has_snapshot_timedelta(self.minimum_backup_age)

View file

@ -209,7 +209,7 @@ def config_gui(config_dict: dict, config_file: str):
[
sg.Text(
"{}\n({})".format(
_t("config_gui.maximum_backup_age"), _t("generic.seconds")
_t("config_gui.minimum_backup_age"), _t("generic.minutes")
),
size=(30, 2),
),

View file

@ -573,11 +573,11 @@ class ResticRunner:
logger.critical("Raw command failed.")
return False, output
def has_snapshot_timedelta(self, delta: int = 86400) -> Optional[datetime]:
def has_snapshot_timedelta(self, delta: int = 1441) -> Optional[datetime]:
"""
Checks if a snapshot exists that is newer that delta seconds
Eg: if delta = -3600 we expect a snapshot newer than an hour ago, and return True if exists
if delta = +3600 we expect a snpashot newer than one hour in future (!), and return True if exists
Checks if a snapshot exists that is newer that delta minutes
Eg: if delta = -60 we expect a snapshot newer than an hour ago, and return True if exists
if delta = +60 we expect a snpashot newer than one hour in future (!), and return True if exists
returns False is too old snapshots exit
returns None if no info available
"""
@ -596,10 +596,10 @@ class ResticRunner:
snapshot["time"],
):
backup_ts = dateutil.parser.parse(snapshot["time"])
snapshot_age_seconds = (
snapshot_age_minutes = (
tz_aware_timestamp - backup_ts
).total_seconds()
if delta - snapshot_age_seconds > 0:
).total_seconds() / 60
if delta - snapshot_age_minutes > 0:
logger.debug(
"Recent snapshot {} of {} exists !".format(
snapshot["short_id"], snapshot["time"]

View file

@ -21,7 +21,7 @@ en:
additional_parameters: Additional parameters
backup_destination: Backup destination
maximum_backup_age: Maximum backup age
minimum_backup_age: Minimum delay between two backups
backup_repo_uri: backup repo URI / path
backup_repo_password: Backup repo password
upload_speed: Upload speed limit (KB/s)

View file

@ -21,7 +21,7 @@ fr:
additional_parameters: Paramètres supplémentaires
backup_destination: Destination de sauvegarde
maximum_backup_age: Age minimal d'une sauvegarde
minimum_backup_age: Délai minimal entre deux sauvegardes
backup_repo_uri: URL / chemin local dépot de sauvegarde
backup_repo_password: Mot de passe dépot de sauvegarde
upload_speed: Vitesse limite de téléversement (KB/s)