Skip to content

Add redbot-setup restore cli command#6709

Open
Jackenmen wants to merge 32 commits intoCog-Creators:V3/developfrom
Jackenmen:restore_command_with_private_core_api
Open

Add redbot-setup restore cli command#6709
Jackenmen wants to merge 32 commits intoCog-Creators:V3/developfrom
Jackenmen:restore_command_with_private_core_api

Conversation

@Jackenmen
Copy link
Copy Markdown
Member

@Jackenmen Jackenmen commented Mar 29, 2026

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

@Jackenmen Jackenmen added this to the 3.5.25 milestone Mar 29, 2026
@Jackenmen Jackenmen added the Type: Feature New feature or request. label Mar 29, 2026
@github-actions github-actions bot added Category: Core - Command-line Interfaces This is related to Red's CLIs (redbot, redbot-launcher, redbot-setup). Category: Core - Other Internals This is related to core internals that don't have a dedicated label. Category: Core - Downloader This is related to the internal Downloader APIs. labels Mar 29, 2026
@github-actions github-actions bot added the Category: Docs - Install Guides This is related to install guides. label Mar 30, 2026
@EternalllZM
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown
Member Author

Jackenmen commented Mar 30, 2026

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
Copy link
Copy Markdown
Member Author

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 Jackenmen added the Blocked By: Other PR Blocked by another PR. label Mar 31, 2026
While nothing prevents future versions from adding more files to
the backup, it seems simpler to get ahead of it...
@Jackenmen
Copy link
Copy Markdown
Member Author

Jackenmen commented Apr 8, 2026

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: Jackenmen@3fb4816

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.

@Jackenmen Jackenmen removed the Blocked By: Other PR Blocked by another PR. label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Core - Command-line Interfaces This is related to Red's CLIs (redbot, redbot-launcher, redbot-setup). Category: Core - Downloader This is related to the internal Downloader APIs. Category: Core - Other Internals This is related to core internals that don't have a dedicated label. Category: Docs - Install Guides This is related to install guides. Type: Feature New feature or request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backup/Downloader] Option to auto-reinstall cogs from backup

2 participants