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

feat: Check if Include folders/files do exists (in case they are removed) #1718

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f6bf5bc
Check if Include folders/files do exists (in case they are removed)
rafaelhdr May 9, 2024
d4556ca
Update CHANGES
rafaelhdr May 9, 2024
5f3a8c7
PEP8 convention
rafaelhdr May 9, 2024
e07d5a1
PEP8 convention
rafaelhdr May 9, 2024
ce4d761
PEP8 convention
rafaelhdr May 9, 2024
27fe2da
refactor code from review
rafaelhdr May 9, 2024
27ac817
PEP8 snake case
rafaelhdr May 9, 2024
4f36503
fixes missing self
rafaelhdr May 9, 2024
9cb8348
PEP8 snake convention
rafaelhdr May 9, 2024
7472f54
PEP8 blank lines
rafaelhdr May 9, 2024
287d129
Merge branch 'dev' into check-included-do-exists
buhtz May 10, 2024
5161ccd
Merge branch 'dev' into check-included-do-exists
buhtz May 12, 2024
45aa011
move warning about missing snapshots for after mounting
rafaelhdr May 20, 2024
c2941ba
display error message on include
rafaelhdr May 20, 2024
6668487
Merge remote-tracking branch 'bit/dev' into check-included-do-exists
rafaelhdr May 20, 2024
205ee49
Merge branch 'dev' into check-included-do-exists
buhtz Jun 18, 2024
03c1050
Merge branch 'dev' into check-included-do-exists
buhtz Jun 28, 2024
bb5969c
document and rename has_missing_includes
rafaelhdr Jul 26, 2024
5416356
Merge remote-tracking branch 'bit/dev' into check-included-do-exists
rafaelhdr Aug 4, 2024
42b5e06
Merge branch 'dev' into check-included-do-exists
buhtz Oct 3, 2024
1f9d888
Merge branch 'dev' into check-included-do-exists
buhtz Nov 28, 2024
3ac5526
Update common/snapshots.py
rafaelhdr Jan 7, 2025
8004348
Update qt/app.py
rafaelhdr Jan 7, 2025
31b7424
review fixes
Jan 7, 2025
7dd5b74
Merge remote-tracking branch 'bit-team/dev' into check-included-do-ex…
Jan 7, 2025
6ab37ec
Update qt/app.py
rafaelhdr Jan 18, 2025
c78c229
move CHANGE to the first section
Jan 18, 2025
309498b
Merge branch 'dev' into check-included-do-exists
buhtz Jan 18, 2025
50bf4bd
Merge branch 'dev' into check-included-do-exists
buhtz Jan 21, 2025
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
@@ -1,6 +1,7 @@
Back In Time

Version 1.4.4-dev (development of upcoming release)
* Fix bug: Check if Include folders/files do exists (in case they are removed) (1586) (@rafaelhdr)
rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved
* Feature: Support SSH proxy (jump) host (#1688) (@cgrinham, Christie Grinham)
* Removed: Context menu in LogViewDialog (#1578)
* Refactor: Replace Config.user() with getpass.getuser() (#1694)
Expand Down
10 changes: 10 additions & 0 deletions common/backintime.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@

parsers = {}

def warningOnTakeSnapshot(config):
hasMissing, missing = snapshots.hasMissing(config.include())
if hasMissing:
msgMissing = ', '.join(missing)
msg = f'{_("The following folders are missing")}: {msgMissing}'
logger.warning(msg)
return True

rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved
def takeSnapshotAsync(cfg, checksum = False):
"""
Fork a new backintime process with 'backup' command which will
Expand All @@ -56,6 +64,7 @@ def takeSnapshotAsync(cfg, checksum = False):
Args:
cfg (config.Config): config that should be used
"""
warningOnTakeSnapshot(cfg)
rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved
cmd = []
if cfg.ioniceOnUser():
cmd.extend(('ionice', '-c2', '-n7'))
Expand Down Expand Up @@ -94,6 +103,7 @@ def takeSnapshot(cfg, force = True):
Returns:
bool: ``True`` if there was an error
"""
warningOnTakeSnapshot(cfg)
rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved
tools.envLoad(cfg.cronEnvFile())
ret = snapshots.Snapshots(cfg).backup(force)
return ret
Expand Down
8 changes: 8 additions & 0 deletions common/po/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,14 @@ msgstr "AVISO"
msgid "Exclude {path} from future snapshots?"
msgstr "Excluir {path} de snapshots futuros?"

#: qt/app.py:1189
msgid "The following folders are missing"
msgstr "As seguintes pastas estão faltando"

#: qt/app.py:1189
msgid "Do you want to proceed?"
msgstr "Deseja prosseguir?"

rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved
#~ msgid " and add your user to group 'fuse'"
#~ msgstr " e adicionar seu usuário para grupo 'fuse'"

Expand Down
19 changes: 19 additions & 0 deletions common/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3104,6 +3104,25 @@ def lastSnapshot(cfg):
return sids[0]


def hasMissing(included):
"""
Check if there are missing files or folders in a snapshot.

Args:
included (list): list of tuples (item, info)

Returns:
tuple: (bool, str) where bool is ``True`` if there are
missing files or folders and str is a message
describing the missing files or folders
"""
notFound = []
for path, info in included:
rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved
if not os.path.exists(path):
buhtz marked this conversation as resolved.
Show resolved Hide resolved
notFound.append(path)
return bool(notFound), notFound
rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == '__main__':
config = config.Config()
snapshots = Snapshots(config)
Expand Down
15 changes: 15 additions & 0 deletions qt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,11 +1182,26 @@ def updateTimeLine(self, refreshSnapshotsList = True):
item = self.timeLine.addSnapshot(sid)
self.timeLine.checkSelection()

def validateOnTakeSnapshot(self):
hasMissing, missing = snapshots.hasMissing(self.config.include())
if hasMissing:
msgMissing = '\n'.join(missing)
msg = f'{_("The following folders are missing")}:\n\n{msgMissing}\n\n{_("Do you want to proceed?")}'
rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved
answer = messagebox.warningYesNo(self, msg)
buhtz marked this conversation as resolved.
Show resolved Hide resolved
return answer == QMessageBox.StandardButton.Yes
return True

def btnTakeSnapshotClicked(self):
proceed = self.validateOnTakeSnapshot()
if not proceed:
return
backintime.takeSnapshotAsync(self.config)
self.updateTakeSnapshot(True)

def btnTakeSnapshotChecksumClicked(self):
proceed = self.validateOnTakeSnapshot()
if not proceed:
return
backintime.takeSnapshotAsync(self.config, checksum = True)
self.updateTakeSnapshot(True)
rafaelhdr marked this conversation as resolved.
Show resolved Hide resolved

Expand Down