rhino-pkg
rhino-pkg copied to clipboard
Two new functions: "Backup" and "Recover"
Hello Rhino Linux Team,
I’d like to submit this pull request to introduce two new utilities: rpk backup and rpk recover. Below are the details of their functionality and rationale.
Intent
The rpk backup utility records the names of all installed packages (from different sources) to create a backup for a specific device. The rpk recover command reads this backup file and installs any missing packages on another system.
Context
This update enables users to log and save their installed package data, allowing them to replicate the same environment on another device using the recover command. This is particularly useful for migration, disaster recovery, or consistent setup across multiple machines.
Logic of backup
- The user selects where to save the backup file (e.g., a default path with a timestamped filename or a custom path/name).
- The utility verifies the file’s safety before writing.
- Installed packages are collected and categorized by their package manager (e.g.,
dpkg,snap).
[username] sudo ./rhino-pkg backup
The backup file's location: '/rhino-pkg_backup_20250213_172315.txt'
Continue (y), or choose your own .txt file (S)? (y/S) y
Creating the file: /rhino-pkg_backup_20250213_172315.txt
Using the file: /rhino-pkg_backup_20250213_172315.txt
Backup location: /rhino-pkg_backup_20250213_172315.txt
Starting backup process...
Collecting installed package names...
Backup completed successfully!
Backup saved to: /rhino-pkg_backup_20250213_172315.txt
SHA256: 9e382d149b9f0e06e120399f86728bf14508670fe4f3f21399f0e614677a23e0
The logic of recover
- Validates the backup file’s readability and integrity.
- Installs missing packages using their respective package managers.
- Displays a summary of failed installations.
- Prompts the user to run a system update and cleanup post-recovery.
$ sudo ./rhino-pkg recover /rhino-pkg_backup_20250213_172315.txt
Using the file: /rhino-pkg_backup_20250213_172315.txt
Do you want to recover files by downloading packages again (WARNING: YOU CANNOT CANCEL THE OPERATION! Internet bandwidth usage warning!)? (y/N) y
Starting recovery...
Do you want to update first? (y/N) N
Skipping update.
Recovering dpkg/apt packages...
accountsservice is already the newest version (23.13.9-7ubuntu1).
Summary:
Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0
'accountsservice' is installed successfully.
acl is already the newest version (2.3.2-2).
Summary:
Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0
'acl' is installed successfully.
adduser is already the newest version (3.137ubuntu2).
Summary:
Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0
'adduser' is installed successfully.
Package adw-gtk-theme is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Error: Package 'adw-gtk-theme' has no installation candidate
Failed to install 'adw-gtk-theme'.
Package adw-gtk3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Error: Package 'adw-gtk3' has no installation candidate
Failed to install 'adw-gtk3'.
.
.
.
Errors:
Failed to install the following dpkg/apt packages:
- adw-gtk-theme
- adw-gtk3
- appmenu-registrar
- celeste
- discord
.
.
.
Failed to install the following Snap packages:
- libsnapd-glib-2-1
- libsnappy1v5
Next Steps
This feature is in beta, and I welcome feedback on:
- Naming conventions (e.g., backup/recover vs. save/restore)
- Code structure improvements
- Edge cases or security considerations
Let me know if any adjustments are needed before merging. I’m happy to iterate further!
Best regards,
@devtracer
Thanks for the great work! Unfortunately we're in the middle of a rewrite to another language, most likely Nushell, and you can find the progress at https://github.com/rhino-linux/rhino-pkg/pull/52.
-------- Original Message -------- On 2/13/25 18:11, devtracer wrote:
Hello Rhino Linux Team,
I’d like to submit this pull request to introduce two new utilities: rpk backup and rpk recover. Below are the details of their functionality and rationale.
Intent
The rpk backup utility records the names of all installed packages (from different sources) to create a backup for a specific device. The rpk recover command reads this backup file and installs any missing packages on another system.
Context
This update enables users to log and save their installed package data, allowing them to replicate the same environment on another device using the recover command. This is particularly useful for migration, disaster recovery, or consistent setup across multiple machines.
Logic of backup
- The user selects where to save the backup file (e.g., a default path with a timestamped filename or a custom path/name).
- The utility verifies the file’s safety before writing.
- Installed packages are collected and categorized by their package manager (e.g., dpkg, snap).
[username] sudo ./rhino-pkg backup The backup file's location: '/rhino-pkg_backup_20250213_172315.txt' Continue (y), or choose your own .txt file (S)? (y/S) y Creating the file: /rhino-pkg_backup_20250213_172315.txt Using the file: /rhino-pkg_backup_20250213_172315.txt Backup location: /rhino-pkg_backup_20250213_172315.txt Starting backup process... Collecting installed package names... Backup completed successfully! Backup saved to: /rhino-pkg_backup_20250213_172315.txt SHA256: 9e382d149b9f0e06e120399f86728bf14508670fe4f3f21399f0e614677a23e0
The logic of recover
- Validates the backup file’s readability and integrity.
- Installs missing packages using their respective package managers.
- Displays a summary of failed installations.
- Prompts the user to run a system update and cleanup post-recovery.
$ sudo ./rhino-pkg recover /rhino-pkg_backup_20250213_172315.txt Using the file: /rhino-pkg_backup_20250213_172315.txt Do you want to recover files by downloading packages again (WARNING: YOU CANNOT CANCEL THE OPERATION! Internet bandwidth usage warning!)? (y/N) y Starting recovery... Do you want to update first? (y/N) N Skipping update. Recovering dpkg/apt packages... accountsservice is already the newest version (23.13.9-7ubuntu1). Summary: Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0 'accountsservice' is installed successfully. acl is already the newest version (2.3.2-2). Summary: Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0 'acl' is installed successfully. adduser is already the newest version (3.137ubuntu2). Summary: Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0 'adduser' is installed successfully. Package adw-gtk-theme is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
Error: Package 'adw-gtk-theme' has no installation candidate Failed to install 'adw-gtk-theme'. Package adw-gtk3 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
Error: Package 'adw-gtk3' has no installation candidate Failed to install 'adw-gtk3'. . . .
Errors:
Failed to install the following dpkg/apt packages:
- adw-gtk-theme
- adw-gtk3
- appmenu-registrar
- celeste
- discord . . . Failed to install the following Snap packages:
- libsnapd-glib-2-1
- libsnappy1v5
Next Steps
This feature is in beta, and I welcome feedback on:
- Naming conventions (e.g., backup/recover vs. save/restore)
- Code structure improvements
- Edge cases or security considerations
Let me know if any adjustments are needed before merging. I’m happy to iterate further!
Best regards,
@.***(https://github.com/devtracer)
You can view, comment on, or merge this pull request online at:
https://github.com/rhino-linux/rhino-pkg/pull/57
Commit Summary
- c11a06f modified: rhino-pkg
- 8ad745e modified: rhino-pkg
- dcdf60f modified: rhino-pkg
- ab73b46 modified: rhino-pkg
- 989d0ae modified: rhino-pkg
- 072bbf4 modified: rhino-pkg
- fd5987b Update README.md
- ebec4fb modified: rhino-pkg
- f8ae6f4 modified: rhino-pkg
- 9e50023 modified: rhino-pkg
- c664cde modified: README.md
File Changes
(2 files)
Patch Links:
- https://github.com/rhino-linux/rhino-pkg/pull/57.patch
- https://github.com/rhino-linux/rhino-pkg/pull/57.diff
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
We should absolutely add this feature to the rewrite, though. We intended for a very similar concept with https://github.com/rhino-linux/horns, which never came to full fruition. Thank you immensely for this!
This is absolutely incredible work. I would personally want to see this merged into the current (bash) version of rhino-pkg, and then we port it to the rewrite (whatever language that may be)
My concern is that there does not seem to be any handling for Pacstall packages, only apt/snap and flatpak. This would absolutely need to be rectified if this is to be merged into rhino-pkg.
Additionally there seems to be no handling for Nala.
We should absolutely add this feature to the rewrite, though. We intended for a very similar concept with rhino-linux/horns, which never came to full fruition. Thank you immensely for this!
Yes absolutely this should be added to the rewrite. Sorry if I didn't mention that in my first message, but that was my intention.
Thanks for the great work! Unfortunately we're in the middle of a rewrite to another language, most likely Nushell, and you can find the progress at #52.
Thank you for your response, @Elsie19, and I’m glad you liked the project! Regarding the rewrite to Nushell (#52), I’d love to contribute to this effort as well.
My idea is to implement the backup and recover functions as a separate Bash script. This approach would:
- Allow users to retain these utilities even during the transition to Nushell.
- Keep the code modular, as these functions are distinct yet related to the core functionality.
I’ll share another idea soon. Looking forward to your thoughts!
Are you familiar with Nushell?
@oklopfer I’m thrilled to hear you liked the idea! My next suggestion aligns perfectly with this: I’d love to contribute to completing the Horns project. Once finalized, the future rpk package could integrate Horns (or a subset of it) to handle these processes.
We can discuss details like:
- Implementation logic
- Programming language choices
- How to best integrate Horns with
rpk
Looking forward to collaborating on this!
Are you familiar with Nushell?
I’m not currently familiar with Nushell, but after looking it up, I find it quite interesting and am eager to learn it!
@ajstrongdev
This is absolutely incredible work. I would personally want to see this merged into the current (bash) version of rhino-pkg, and then we port it to the rewrite (whatever language that may be)
I'm absolutely delighted to hear that you liked my project! It truly means a lot, and I’d be more than happy to contribute!
My concern is that there does not seem to be any handling for Pacstall packages, only apt/snap and flatpak. This would absolutely need to be rectified if this is to be merged into rhino-pkg.
Yes, you're completely right and I agree! I’ve included handling for Pacstall packages. Here’s how it works:
- Lines 123–124: Collects installed Pacstall packages and saves them to the backup file.
- Line 197: Tracks Pacstall packages that fail to install.
- Lines 210–211: Detects the Pacstall flag to switch to Pacstall’s installation method.
- Lines 228–231: Recovers Pacstall packages using:
pacstall -I <package> - Lines 265–270: Reports any Pacstall packages that failed to install.
Let me know if there’s anything else I can clarify or improve!
Additionally there seems to be no handling for Nala.
When the recovery process is complete, the code asks the user if they want to run an update and a cleanup as well. If the user agrees, the cleanup process will also be executed. If it's necessary to enforce a cleanup, we can modify the logic accordingly.
Is the recovery supposed to be prompted throughout? pacstall -I will prompt the user on multiple steps.
Is the recovery supposed to be prompted throughout? pacstall -I will prompt the user on multiple steps.
Could you clarify further? The recovery process is designed to reinstall the required packages. The code identifies packages under the Pacstall tag and passes them to Pacstall for installation. If there are specific prompts or steps during pacstall -I that need to be addressed, please let me know!
I assume he's talking about the -P flag on pacstall which bypasses prompts.
I assume he's talking about the -P flag on pacstall which bypasses prompts.
Thanks for the explanation. So as it seems, I have to change -I to -P, am I right?
I assume he's talking about the -P flag on pacstall which bypasses prompts.
Thanks for the explanation. So as it seems, I have to change
-Ito-P, am I right?
You should use -PI.
You should use -PI.
Ok, I'll edit the code. Thanks.