Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging for canBackup check #1328

Merged
merged 4 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Upcoming Release
* Desktop integration: update .desktop file to mark Back In Time as a single main window program (#1258)
* Bugfix: AttributeError in "Diff Options" dialog (#898)
* Bugfix: Settings GUI: "Save password to Keyring" was disabled due to "no appropriate keyring found" (#1321)
* Bugfix: Avoid logging errors while waiting for a target drive to be mounted (#1142, #1143, #1328)
* Documentation update: correct description of profile<N>.schedule.time in backintime-config manpage (#1270)
* Translation update: Brazilian Portuguese (#1267)
* Translation update: Italian (#1110, #1123)
Expand Down
12 changes: 8 additions & 4 deletions common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,10 +1376,14 @@ def canBackup(self, profile_id = None):
if not self.isConfigured(profile_id):
return False

if not os.path.isdir(self.snapshotsFullPath(profile_id)):
logger.error("%s does not exist"
%self.snapshotsFullPath(profile_id),
self)
path = self.snapshotsFullPath(profile_id)

if not os.path.exists(path):
return False

if not os.path.isdir(path):
# path exists, but is no dir: something's very wrong.
logger.error("%s is not a directory"%path, self)
return False

return True
Expand Down
1 change: 1 addition & 0 deletions common/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ def backup(self, force = False):
gettext.ngettext('Waiting %s second.', 'Waiting %s seconds.', 30) % 30,
30)
for counter in range(30, 0, -1):
logger.info("Cannot start snapshot yet: target directory not accessible. Waiting 1s.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just like to point out that since backintime by default logs at INFO this is potentially 30 non-informative log lines in syslog. A more sensible approach would be to either 1. not log this or 2. if logging this is crucial (I don't believe it is since the failure that can happen is logged below) then count how many times the iteration has happened and only log if it is greater than 1.

time.sleep(1)
if self.config.canBackup():
break
Expand Down