mirror of
https://github.com/netinvent/npbackup.git
synced 2025-10-19 09:56:39 +08:00
Convert minimum_backup_age to minutes
This commit is contained in:
parent
00c30c1731
commit
6ab6ed9ef3
6 changed files with 13 additions and 13 deletions
|
@ -49,7 +49,7 @@ empty_config_dict = {
|
||||||
"exclude_caches": True,
|
"exclude_caches": True,
|
||||||
"priority": "low",
|
"priority": "low",
|
||||||
},
|
},
|
||||||
"repo": {"minimum_backup_age": 86400},
|
"repo": {"minimum_backup_age": 1440},
|
||||||
"prometheus": {},
|
"prometheus": {},
|
||||||
"env": {},
|
"env": {},
|
||||||
"options": {},
|
"options": {},
|
||||||
|
|
|
@ -293,7 +293,7 @@ class NPBackupRunner:
|
||||||
self.config_dict["repo"]["minimum_backup_age"]
|
self.config_dict["repo"]["minimum_backup_age"]
|
||||||
)
|
)
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
self.minimum_backup_age = 86400
|
self.minimum_backup_age = 1440
|
||||||
|
|
||||||
self.restic_runner.verbose = self.verbose
|
self.restic_runner.verbose = self.verbose
|
||||||
self.restic_runner.dry_run = self.dry_run
|
self.restic_runner.dry_run = self.dry_run
|
||||||
|
@ -326,7 +326,7 @@ class NPBackupRunner:
|
||||||
def check_recent_backups(self) -> bool:
|
def check_recent_backups(self) -> bool:
|
||||||
logger.info(
|
logger.info(
|
||||||
"Searching for a backup newer than {} ago.".format(
|
"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)
|
result = self.restic_runner.has_snapshot_timedelta(self.minimum_backup_age)
|
||||||
|
|
|
@ -209,7 +209,7 @@ def config_gui(config_dict: dict, config_file: str):
|
||||||
[
|
[
|
||||||
sg.Text(
|
sg.Text(
|
||||||
"{}\n({})".format(
|
"{}\n({})".format(
|
||||||
_t("config_gui.maximum_backup_age"), _t("generic.seconds")
|
_t("config_gui.minimum_backup_age"), _t("generic.minutes")
|
||||||
),
|
),
|
||||||
size=(30, 2),
|
size=(30, 2),
|
||||||
),
|
),
|
||||||
|
|
|
@ -573,11 +573,11 @@ class ResticRunner:
|
||||||
logger.critical("Raw command failed.")
|
logger.critical("Raw command failed.")
|
||||||
return False, output
|
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
|
Checks if a snapshot exists that is newer that delta minutes
|
||||||
Eg: if delta = -3600 we expect a snapshot newer than an hour ago, and return True if exists
|
Eg: if delta = -60 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
|
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 False is too old snapshots exit
|
||||||
returns None if no info available
|
returns None if no info available
|
||||||
"""
|
"""
|
||||||
|
@ -596,10 +596,10 @@ class ResticRunner:
|
||||||
snapshot["time"],
|
snapshot["time"],
|
||||||
):
|
):
|
||||||
backup_ts = dateutil.parser.parse(snapshot["time"])
|
backup_ts = dateutil.parser.parse(snapshot["time"])
|
||||||
snapshot_age_seconds = (
|
snapshot_age_minutes = (
|
||||||
tz_aware_timestamp - backup_ts
|
tz_aware_timestamp - backup_ts
|
||||||
).total_seconds()
|
).total_seconds() / 60
|
||||||
if delta - snapshot_age_seconds > 0:
|
if delta - snapshot_age_minutes > 0:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Recent snapshot {} of {} exists !".format(
|
"Recent snapshot {} of {} exists !".format(
|
||||||
snapshot["short_id"], snapshot["time"]
|
snapshot["short_id"], snapshot["time"]
|
||||||
|
|
|
@ -21,7 +21,7 @@ en:
|
||||||
additional_parameters: Additional parameters
|
additional_parameters: Additional parameters
|
||||||
|
|
||||||
backup_destination: Backup destination
|
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_uri: backup repo URI / path
|
||||||
backup_repo_password: Backup repo password
|
backup_repo_password: Backup repo password
|
||||||
upload_speed: Upload speed limit (KB/s)
|
upload_speed: Upload speed limit (KB/s)
|
||||||
|
|
|
@ -21,7 +21,7 @@ fr:
|
||||||
additional_parameters: Paramètres supplémentaires
|
additional_parameters: Paramètres supplémentaires
|
||||||
|
|
||||||
backup_destination: Destination de sauvegarde
|
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_uri: URL / chemin local dépot de sauvegarde
|
||||||
backup_repo_password: Mot de passe dépot de sauvegarde
|
backup_repo_password: Mot de passe dépot de sauvegarde
|
||||||
upload_speed: Vitesse limite de téléversement (KB/s)
|
upload_speed: Vitesse limite de téléversement (KB/s)
|
||||||
|
|
Loading…
Add table
Reference in a new issue