Add redbot-setup restore cli command #6709

Merged
Jackenmen merged 33 commits from restore_command_with_private_core_api into V3/develop 2026-05-13 21:18:17 +02:00
Jackenmen commented 2026-03-29 22:33:03 +02:00 (Migrated from github.com)

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

### 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
EternalllZM commented 2026-03-30 18:02:11 +02:00 (Migrated from github.com)

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> ~/.local command, that is removed in this PR.

data_path handles 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.

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> ~/.local` command, that is removed in this PR. `data_path` handles 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.
Jackenmen commented 2026-03-30 22:33:26 +02:00 (Migrated from github.com)

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> ~/.local command, that is removed in this PR.

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.

data_path handles the restore location, would it be worth adding a check for file access?

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.

How would that be handled on a Windows to Linux or vise versa restore

The updated code should make it so this fails on the is_absolute() call.

> 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> ~/.local` command, that is removed in this PR. 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. > `data_path` handles the restore location, would it be worth adding a check for file access? 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. > How would that be handled on a Windows to Linux or vise versa restore The updated code should make it so this fails on the `is_absolute()` call.
Jackenmen commented 2026-03-31 02:38:37 +02:00 (Migrated from github.com)

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.

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.
Jackenmen commented 2026-04-08 21:33:34 +02:00 (Migrated from github.com)

I've made a slight change to metadata stored in the backup file - instead of a backup.version file storing just the version number, there's now a backup_details.json file with one backup_version key. 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@3fb4816403

Another small change is the addition of dereference=True parameter to tarfile.open() to ensure we backup the actual files rather than symlinks, if any are present in the data dir.

I've made a slight change to metadata stored in the backup file - instead of a `backup.version` file storing just the version number, there's now a `backup_details.json` file with one `backup_version` key. 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: https://github.com/Jackenmen/Red-DiscordBot/commit/3fb4816403d034ee7f08c8c59c603c303394ad65 Another small change is the addition of `dereference=True` parameter to `tarfile.open()` to ensure we backup the actual files rather than symlinks, if any are present in the data dir.
palmtree5 (Migrated from github.com) reviewed 2026-05-13 21:02:17 +02:00
@ -372,6 +387,379 @@ async def remove_instance_interaction() -> None:
await remove_instance(selected, interactive=True)
palmtree5 (Migrated from github.com) commented 2026-05-13 21:02:17 +02:00

Can we change backuped to backed up here?

Can we change `backuped` to `backed up` here?
palmtree5 commented 2026-05-13 21:05:11 +02:00 (Migrated from github.com)

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

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
Jackenmen (Migrated from github.com) reviewed 2026-05-13 21:16:31 +02:00
@ -372,6 +387,379 @@ async def remove_instance_interaction() -> None:
await remove_instance(selected, interactive=True)
Jackenmen (Migrated from github.com) commented 2026-05-13 21:16:31 +02:00

Absolutely!

Absolutely!
palmtree5 (Migrated from github.com) approved these changes 2026-05-13 21:17:52 +02:00
Sign in to join this conversation.
No reviewers
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 milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!6709
No description provided.