Add redbot-setup restore cli command #6709
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!6709
Loading…
Reference in a new issue
No description provided.
Delete branch "restore_command_with_private_core_api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description of the changes
Fixes #2947, depends on #6696, supersedes #3681
I added progress bars to indicate to the user that the command does something but they're surely not the most accurate progress bars - progress bar for (un)packing archives are based on file amount, not on file size and progress bar for downloading repos is based on repo amount. I'm open to improving it but I think it still serves its purpose even if it's not very linear.
Backup can now have a version of its own in case we need to change something about its format later.
Docs: https://red-discordbot--6709.org.readthedocs.build/en/6709/backup_red.html
Have the changes in this PR been tested?
Yes
In regards to the docs on this, the current backup and restore page mentions (the possible need of) fixing permissions on Linux with the
sudo chown -R <user>:<user> ~/.localcommand, that is removed in this PR.data_pathhandles the restore location, would it be worth adding a check for file access? How would that be handled on a Windows to Linux or vise versa restore? Regardless, I think the command should remain in the backup/restore process docs just in case.There should be no need for this unless the user has a seriously broken system. That's not on us to help with, and users will definitely just try running this command if something breaks for them due to unrelated reasons.
Yes, I missed that earlier and have just noticed in testing that we are, in fact, not checking whether the path is accessible at any point. I just fixed that.
The updated code should make it so this fails on the
is_absolute()call.Okay, I added support for non-interactive use, and this is now (again) ready for review. Please note, however, that as described in the description, this PR depends on #6696 to work correctly, and the changeset from that PR is not included in this PR's branch.
I've made a slight change to metadata stored in the backup file - instead of a
backup.versionfile storing just the version number, there's now abackup_details.jsonfile with onebackup_versionkey. While there was nothing stopping future versions of the backup format from storing additional metadata files, I figured it would be simpler if one could just use the same file for more purposes in the future.Notably, I'm hoping this command could, in the future, have flags for making copies of installed cogs and installed repos, and the metadata would then have additional keys that tell you if such flags were used for the backup.
Here's an example of how such a change to the metadata would look in practice:
github.com/Jackenmen/Red-DiscordBot@3fb4816403Another small change is the addition of
dereference=Trueparameter totarfile.open()to ensure we backup the actual files rather than symlinks, if any are present in the data dir.@ -372,6 +387,379 @@ async def remove_instance_interaction() -> None:await remove_instance(selected, interactive=True)Can we change
backupedtobacked uphere?I tested this just now backing up my bot on Ubuntu 24.04 and restoring on Windows 11, it worked just fine and correctly told me it could not install 2 of the cogs, one because the repo wasn't setup on the bot at time of backup and one because the cog doesn't exist in the repo anymore. I did leave a comment on one minor thing in the code with wording on output of the settings as they were at time of backup though
@ -372,6 +387,379 @@ async def remove_instance_interaction() -> None:await remove_instance(selected, interactive=True)Absolutely!