Skip to content

Conversation

@n8marti
Copy link
Collaborator

@n8marti n8marti commented Feb 26, 2025

Get backup and restore working for CLI (prep for getting general backup/restore working)

  • Split backup/restore into own module and Include unittests
  • Ensure backup works to fixed and removable drives (snap pkg needs additional permission from user for removable drives)
  • Ensure restore works on clean Logos install
  • Ensure restore works on existing Logos install (i.e. overwriting existing data)
  • Re-publish CLI backup/restore options

@n8marti
Copy link
Collaborator Author

n8marti commented Feb 26, 2025

We might need/want to backup/restore Logos registry keys, as well as user data folders.

Copy link
Contributor

@ctrlaltf24 ctrlaltf24 left a comment

Choose a reason for hiding this comment

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

Nothing new, some thoughts feel free to ignore, I know you're still working

return bar

# De-dup
if message != self._last_status:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the bar print even if the status didn't change?

We may consider changing the Downloading.... status to use a percentage instead of adding dots


from . import system
from . import utils
# from . import utils
Copy link
Contributor

Choose a reason for hiding this comment

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

?

while t.is_alive():
i += 1
i = i % 20
app.status(f"{message}{"." * i}\r")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use progress in status rather than adding dots

if mode == 'restore':
if not app.conf.logos_exe:
app.exit("Cannot restore, Logos is not installed")
dst_dir = Path(app.conf.logos_exe).parent
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this use logos app data Dir instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had the same question, but I think the Logos app should be installed before trying to restore a backup. Otherwise installing Logos over existing data directories might clobber them? Not sure. Also, is app.conf.logos_exe generic enough to be defined as the Verbum exe path as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, is app.conf.logos_exe generic enough to be defined as the Verbum exe path as well?

Yup

@n8marti
Copy link
Collaborator Author

n8marti commented Feb 26, 2025

Consider a file chooser for setting Backup dir:
The TUI one is a text field with mkdir. tui_app.py:L774

@n8marti n8marti marked this pull request as ready for review February 26, 2025 16:19
@n8marti n8marti requested review from ctrlaltf24 and thw26 February 26, 2025 16:19
@thw26
Copy link
Collaborator

thw26 commented Mar 1, 2025

Consider a file chooser for setting Backup dir: The TUI one is a text field with mkdir. tui_app.py:L774

cf. #228 for links to some potential curses file browsers.

@ctrlaltf24 ctrlaltf24 changed the title Fix backup cli fix: backup cli Mar 6, 2025
@ctrlaltf24
Copy link
Contributor

ctrlaltf24 commented Mar 6, 2025

Ran additional tests on 78aeef0:

  • Backup before user login -> success
  • Backup before user login, then login, then restore backup before login -> not logged in
  • Backup with logos account one, restore backup before login, login with second logos account, restore logos account one backup -> logos account one restored
  • Backup one one directory, change install dir, install into that directory, restore -> success

Made a PR into this branch with a refactor to using python inheritance rather than setting source/dest dir manually. #360

Copy link
Contributor

@ctrlaltf24 ctrlaltf24 left a comment

Choose a reason for hiding this comment

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

Approved, although would like to see #360 merged into this first.

question = "New or existing folder to store backups in: "
options = [PROMPT_OPTION_DIRECTORY]
output = Path(self._ask_if_not_found("backup_dir", question, options))
output.mkdir(parents=True, exist_ok=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

What you have here is fine, or you could move https://github.com/FaithLife-Community/OuDedetai/pull/345/files#diff-07bb26aae0eae6d2749c28c992609c0619b8a27c628a8dc5efc075308f20181fR29-R35 here

Rational for the logic here was the return type is Path, so it'd be nice if it exists. Nice to have valid values returned from Config



def get_path_size(file_path):
def get_path_size(file_path: Path|str) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no need to change, but os.walk https://www.geeksforgeeks.org/os-walk-python/ is well designed for this task. Just FYI, not requiring you to change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure. Is it significantly faster? Less memory and/or CPU intensive? Or is there some other benefit to os.walk over Path.rglob?

Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't require recursion is the main benefit which may be inconsequentially faster

rather than initializing destination_dir to none, then setting it, use abstract functions to populate them.
thw26
thw26 previously requested changes Mar 7, 2025
backup.backup(self)
else:
control.restore(self)
backup.restore(self)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to re-enable backup and restore in the menu below, lines 983–984.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps I misunderstood, but this PR is not intended to fix #197, only partially so, correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

The way I understood it was an improvement, related to #197, but not aimed at fixing it. I looked to the PR description to determine scope rather than the issue

Tested:
- clean install
- clean install, backup #1, login, logos open, backup #2, restore #1, logos at login, close, restore #2, logos open
@ctrlaltf24 ctrlaltf24 dismissed thw26’s stale review March 10, 2025 15:36

Discussed in other channel - they're willing to merge this

@ctrlaltf24 ctrlaltf24 merged commit 53f90db into main Mar 10, 2025
1 check passed
@ctrlaltf24 ctrlaltf24 deleted the fix-backup-cli branch March 10, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants