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 30 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 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
6423a87
Merge branch 'dev' into check-included-do-exists
buhtz Feb 2, 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
Prev Previous commit
Next Next commit
PEP8 blank lines
rafaelhdr committed May 9, 2024
commit 7472f54d4df34789f3bd10cd1071a197c36be4f7
31 changes: 31 additions & 0 deletions common/backintime.py
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@

parsers = {}


def warning_on_take_snapshot(config):
buhtz marked this conversation as resolved.
Show resolved Hide resolved
missing = snapshots.has_missing(config.include())

@@ -56,6 +57,7 @@ def warning_on_take_snapshot(config):
msg = f'The following folders are missing: {msg}'
logger.warning(msg)


def takeSnapshotAsync(cfg, checksum = False):
"""
Fork a new backintime process with 'backup' command which will
@@ -91,6 +93,7 @@ def takeSnapshotAsync(cfg, checksum = False):
pass
subprocess.Popen(cmd, env = env)


def takeSnapshot(cfg, force = True):
"""
Take a new snapshot.
@@ -108,6 +111,7 @@ def takeSnapshot(cfg, force = True):
ret = snapshots.Snapshots(cfg).backup(force)
return ret


def _mount(cfg):
"""
Mount external filesystems.
@@ -123,6 +127,7 @@ def _mount(cfg):
else:
cfg.setCurrentHashId(hash_id)


def _umount(cfg):
"""
Unmount external filesystems.
@@ -135,6 +140,7 @@ def _umount(cfg):
except MountException as ex:
logger.error(str(ex))


def createParsers(app_name = 'backintime'):
"""
Define parsers for commandline arguments.
@@ -630,6 +636,7 @@ def join(args, subArgs):

return args


def printHeader():
"""
Print application name, version and legal notes.
@@ -643,6 +650,7 @@ def printHeader():
print("under certain conditions; type `backintime --license' for details.")
print('')


class PseudoAliasAction(argparse.Action):
"""
Translate '--COMMAND' into 'COMMAND' for backwards compatibility.
@@ -669,6 +677,7 @@ def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, 'replace', replace)
setattr(namespace, 'alias', alias)


def aliasParser(args):
"""
Call commands which where given with leading -- for backwards
@@ -686,6 +695,7 @@ def aliasParser(args):
if 'func' in dir(newArgs):
newArgs.func(newArgs)


def getConfig(args, check = True):
"""
Load config and change to profile selected on commandline.
@@ -723,6 +733,7 @@ def getConfig(args, check = True):
cfg.forceUseChecksum = args.checksum
return cfg


def setQuiet(args):
"""
Redirect :py:data:`sys.stdout` to ``/dev/null`` if ``--quiet`` was set on
@@ -744,6 +755,7 @@ def setQuiet(args):
atexit.register(force_stdout.close)
return force_stdout


class printLicense(argparse.Action):
"""
Print custom license
@@ -756,6 +768,7 @@ def __call__(self, *args, **kwargs):
print(license_path.read_text('utf-8'))
sys.exit(RETURN_OK)


class printDiagnostics(argparse.Action):
"""
Print information that is helpful for the support team
@@ -774,6 +787,7 @@ def __call__(self, *args, **kwargs):

sys.exit(RETURN_OK)


def backup(args, force = True):
"""
Command for force taking a new snapshot.
@@ -793,6 +807,7 @@ def backup(args, force = True):
ret = takeSnapshot(cfg, force)
sys.exit(int(ret))


def backupJob(args):
"""
Command for taking a new snapshot in background. Mainly used for cronjobs.
@@ -808,6 +823,7 @@ def backupJob(args):
"""
cli.BackupJobDaemon(backup, args).start()


def shutdown(args):
"""
Command for shutting down the computer after the current snapshot has
@@ -852,6 +868,7 @@ def shutdown(args):
sd.shutdown()
sys.exit(RETURN_OK)


def snapshotsPath(args):
"""
Command for printing the full snapshot path of current profile.
@@ -874,6 +891,7 @@ def snapshotsPath(args):
print(msg.format(cfg.snapshotsFullPath()), file=force_stdout)
sys.exit(RETURN_OK)


def snapshotsList(args):
"""
Command for printing a list of all snapshots in current profile.
@@ -904,6 +922,7 @@ def snapshotsList(args):
_umount(cfg)
sys.exit(RETURN_OK)


def snapshotsListPath(args):
"""
Command for printing a list of all snapshots paths in current profile.
@@ -934,6 +953,7 @@ def snapshotsListPath(args):
_umount(cfg)
sys.exit(RETURN_OK)


def lastSnapshot(args):
"""
Command for printing the very last snapshot in current profile.
@@ -960,6 +980,7 @@ def lastSnapshot(args):
_umount(cfg)
sys.exit(RETURN_OK)


def lastSnapshotPath(args):
"""
Command for printing the path of the very last snapshot in
@@ -988,6 +1009,7 @@ def lastSnapshotPath(args):
_umount(cfg)
sys.exit(RETURN_OK)


def unmount(args):
"""
Command for unmounting all filesystems.
@@ -1005,6 +1027,7 @@ def unmount(args):
_umount(cfg)
sys.exit(RETURN_OK)


def benchmarkCipher(args):
"""
Command for transferring a file with scp to remote host with all
@@ -1028,6 +1051,7 @@ def benchmarkCipher(args):
logger.error("SSH is not configured for profile '%s'!" % cfg.profileName())
sys.exit(RETURN_ERR)


def pwCache(args):
"""
Command for starting password cache daemon.
@@ -1058,6 +1082,7 @@ def pwCache(args):
daemon.run()
sys.exit(ret)


def decode(args):
"""
Command for decoding paths given paths with 'encfsctl'.
@@ -1092,6 +1117,7 @@ def decode(args):
_umount(cfg)
sys.exit(RETURN_OK)


def remove(args, force = False):
"""
Command for removing snapshots.
@@ -1112,6 +1138,7 @@ def remove(args, force = False):
_umount(cfg)
sys.exit(RETURN_OK)


def removeAndDoNotAskAgain(args):
"""
Command for removing snapshots without asking before remove
@@ -1126,6 +1153,7 @@ def removeAndDoNotAskAgain(args):
"""
remove(args, True)


def smartRemove(args):
"""
Command for running Smart-Remove from Terminal.
@@ -1159,6 +1187,7 @@ def smartRemove(args):
logger.error('Smart Remove is not configured.')
sys.exit(RETURN_NO_CFG)


def restore(args):
"""
Command for restoring files from snapshots.
@@ -1188,6 +1217,7 @@ def restore(args):
_umount(cfg)
sys.exit(RETURN_OK)


def checkConfig(args):
"""
Command for checking the config file.
@@ -1215,5 +1245,6 @@ def checkConfig(args):
file = force_stdout)
sys.exit(RETURN_ERR)


if __name__ == '__main__':
startApp()
5 changes: 5 additions & 0 deletions qt/app.py
Original file line number Diff line number Diff line change
@@ -1933,6 +1933,7 @@ def eventFilter(self, receiver, event):
return super(ExtraMouseButtonEventFilter, self) \
.eventFilter(receiver, event)


class RemoveSnapshotThread(QThread):
"""
remove snapshots in background thread so GUI will not freeze
@@ -1968,6 +1969,7 @@ def run(self):
if self.config.inhibitCookie:
self.config.inhibitCookie = tools.unInhibitSuspend(*self.config.inhibitCookie)


class FillTimeLineThread(QThread):
"""
add snapshot IDs to timeline in background
@@ -1985,6 +1987,7 @@ def run(self):

self.parent.snapshotsList.sort()


class SetupCron(QThread):
"""
Check crontab entries on startup.
@@ -1996,6 +1999,7 @@ def __init__(self, parent):
def run(self):
self.config.setupCron()


def debugTrace():
"""
Set a tracepoint in the Python debugger that works with Qt
@@ -2004,6 +2008,7 @@ def debugTrace():
pyqtRemoveInputHook()
set_trace()


if __name__ == '__main__':
cfg = backintime.startApp('backintime-qt')