Skip to content

Recovery System

prototype74 edited this page Mar 9, 2022 · 12 revisions

The Recovery System is a special service by HyperUBot. It should help the user to be able to recover the userbot from backups or generating new backups to be on the safe side. It's also responsible to apply new updates for HyperUBot. This page will explain the usage and the options the Recovery System does offer.

Do not delete the Recovery System. This will break the update mechanism of HyperUBot!

Start the Recovery System

To start into the Recovery System, locate to HyperUBot's directory and run the following command:

  • Docker: Run docker image/container then select Recovery System
  • POSIX systems: python3 recovery.py (if it fails, try it by python version e.g. python3.8 recovery.py)
  • Windows: python recovery.py

Options

There are some options such as start options to HyperUBot, applying updates manually or reinstall the whole userbot.

1. Start HyperUBot

This option will open a submenu which allow the user to decide to start the userbot in normal or special mode

1.1 Normal

Starts the userbot in normal mode without any special argument

1.2 Safe mode

Starts the userbot in a special mode with the following restrictions:

  • Disabled user modules
  • Only UBOT_LANG config will be loaded from optional configurations (if available)

This is useful to remove broken/faulty modules without getting spammed with errors.

1.3 Advanced safe mode:

Similar to Safe mode but with additional restrictions:

  • Includes everything from safe mode
  • Only core built-in modules

Core built-in modules are:

  • Feauture Manager
  • Modules Utils
  • Package Manager
  • System Tools
  • Updater

1.4 Core only mode:

Starts the userbot in an emergency mode with the following restrictions:

  • Includes everything from advanced safe mode
  • Disabled all modules
  • Optional configs will not be loaded at all

This option is very unlikely to need but useful to check if crashes are caused by built-in modules and/or optional configs.

Note: Start HyperUBot is not available on Windows

2. Clear caches

Clears the generated CPython caches in HyperUBot. Useful to remove leftovers from deleted modules.

3. Apply update

The Recovery System also offers an option to apply bot updates manually. To do so, you need to get update.zip, it's rules.py and create the required directory manually before you start the recovery.

Get the update package manually on POSIX systems

Locate to HyperUBot's directory and run the following commands one by one in your terminal:

mkdir releases
get_release=$(curl -H "Accept: application/json" "https://api.github.com/repos/prototype74/HyperUBot/releases/latest")
zip_pkg=$(grep '"zipball_url"' <<< "$get_release" | cut -d '"' -f4)
rul_py=$(grep '"browser_download_url"' <<< "$get_release" | cut -d '"' -f4)
curl -L "$zip_pkg" --output ./releases/update.zip
curl -L "$rul_py" --output ./releases/rules.py

Check in releases directory if update.zip and rules.py exists or if the file sizes are not zero. Simply check it by executing ls -l releases in your terminal.

Get the update package manually on Windows

Locate to HyperUBot's directory and run the following commands one by one in PowerShell:

New-Item -Path . -Name "releases" -ItemType "directory"
$get_release = Invoke-WebRequest -Uri "https://api.github.com/repos/prototype74/HyperUBot/releases/latest"
$json_obj = ConvertFrom-Json $([String]::new($get_release.Content))
$zip_pkg = $json_obj.zipball_url
$rul_py = $json_obj.assets.browser_download_url
Invoke-WebRequest $zip_pkg -OutFile .\releases\update.zip
Invoke-WebRequest $rul_py -OutFile .\releases\rules.py

Check in releases directory if update.zip and rules.py exists or if the file sizes are not zero. Simply check it by executing Get-ChildItem -Path releases in PowerShell.

Get the commit ID

Go to the Releases section of HyperUBot's repository. To the left side bar (mobile version: on top) there is the commit ID below (mobile version: it's next to) the tag version e.g. c2c04f6 (v6.3.1 release) with a green check mark. Copy the ID, you will need it to apply the recently downloaded update.

Apply the update manually

  1. Start the Recovery System now
  2. Select Apply update option
  3. Input the commit ID
  4. Wait for the Recovery to finish the update

That's it! It's definitely more complex than the automatic way, the Updater module usually do. So apply update manually only if it's actually necessary.

4. Backup current version

This will backup the current installed version. Generated backups are stored in a backup folder in HyperUBot's directory. If a backup with the same version does exist already, the Recovery System will overwrite the old backup archive.

5. Restore

Lists generated backups and restores the selected backup archive.

Warning: performing a restore CANNOT be undone!

6. Reinstall HyperUBot

This option will delete all downloaded user modules, the configurations including the string session and any other data in HyperUBot's directory. At last, the latest release will be installed automatically and you have to setup everything again

Warning: this process CANNOT be undone!

Displayed information

It may be possible that the Recovery System does display information on top of the Main menu (colored).

"Directory is a local git repository"

Some options will be colored to yellow, it's just a warning that these options can break the git history of your git repository. If you take changes in the source then you shouldn't ignore this warning.

"Directory might be git initialized"

Similar to Directory is a local git repository the only difference is the Recovery System wasn't able to detect the actually git history but detected an initialized .git folder.

"HyperUBot version: X.X.X or Unknown"

Displays the current installed version. If it's Unknown it could be possible that HyperUBot isn't installed at all, installed but broken or an older version is installed.

"HyperUBot is not installed"

This means as it is mentioned above, the userbot isn't installed and many options will be disabled. This could happen after a failed update or due to other reasons that made the userbot directory unusable. The possible options are to restore a backup or in worst case reinstalling the userbot.