hdansin Any good recommendations for backup software?
RESTIC For Backups
Yes. It's called restic, and it's in the repository.
I wrote a few simple scripts to do a backup with the command backup
, and then do an update with the command up
. The script first copies a list of packages to your home directory that have been added to the system since it was installed, and then it does a backup that includes that list of installed packages, but excludes stuff that doesn't need to be backed up. Installing restic is trivial, like installing any other .eopkg package.
To initialize a backup location (repository), the command is:
restic init -r YOUR REPOSITORY LOCATION
, where you provide your actual repository location.
Restic will create an empty repository there, and ask for a password you'll use to access it, when requested. I simply use my regular user password, which is easy for me to remember, and there doesn't seem to be any reason not to. If that password should ever be compromised, I'd have a lot more to worry about than someone's being able to access my backup repository.
Pruning The Backups
To save space, my script is designed to remove the oldest backup in the repository each time you've added a new one, leaving just the most recent five including the new one. I assume that if you've just found an issue that requires restoring the system, you likely won't need more than the very last backup, so saving the last five is probably overkill for many folks, but I'm backing up to a NAS that has terabytes of empty space. If your backup destination is smaller, you could easily modify the script to save just the last backup, or the last two, and so on based on your comfort level.
So, in a worst case, you would first reinstall the OS, which on Solus takes just minutes, then install restic and use it to restore your latest backup, which restores the contents of your home directory, and that will include the list of packages that were added since your original installation. And then use eopkg to install that list of packages, to replace everything you've added to the system since you first installed it. That should leave you where you were immediately prior to having the problem that caused you to need that backup.
Using the Script
So, what it boils down to is this. Before every new sync is installed, I run these two commands:
backup
up
to do the backup first and then prune the repository to remove the oldest backup and add most recent one. And finally to install the update.
Modify My Script As Needed
I'll include my script(s) here, but since your backup destination will be different than mine, you'll need to make some modifications. And anywhere you find the user name "jerry" you should replace it with yours. I left my name in place to make it easy to tell where your name should go. Also in the restic backup
command, there are some arguments that start with -e
. Those exclude some really big things that don't need to be backed up, to save some time. Check those arguments, as yours will certainly be different, but I left these to show how to exclude unnessary stuff from the backup.
Testing Your Modifications
The backup part of this script has been used hundreds of times, and it should work perfectly once you've modified it to fit your needs. And you can safely test it over and over again, if you need to as you make those modifications. When you've got it working right, simply begin using it before the next sync. Before long, any previous tests will have been pruned anyway, as your set of backups is trimmed to the number you decided to keep. Or, if you want, you can simply delete your repository and initialize it again, although there should be little need to do that.
NOTE: _The restore part has never been tested_, because I've never needed to use it in all the years I've been using restic. But it uses just a simple eopkg it
command, like ones we've all used over and over again, so it should work fine. But if it would make you feel more at ease, you could test it on a computer other than your daily driver, to confirm that it would correctly restore a copy of that daily driver machine from a backup you've made.
Here's The Script(s)
These are exactly what I use, copied from my bashrc file. So they're all fully tested, and should need no modifications other that what's needed to adjust them for your use. Make whatever changes are needed to adapt these scripts to your system, and afterwards, simply add it to your bashrc file, or if you're not using bash, the rc file for the terminal emulator you do use. That way, it will become available each time you start your terminal.
#
# Related to updates
#
alias copyPackages="eopkg li | cut -d ' ' -f 1 | tr '\n' ' ' > /home/jerry/InstalledPackages"
alias restorePackages='sudo eopkg install $(cat InstalledPackages)'
alias eu='sudo eopkg upgrade && sync'
alias rmo='eopkg rmo -y'
alias ed='sudo eopkg delete-cache && sudo journalctl --vacuum-time=3d --vacuum-size=50M && sync'
alias fl='flatpak update -y && flatpak remove --unused -y'
alias up='eu && rmo && ed && fl'
alias checkUpgrades='sudo eopkg ur && eopkg lu | tee LastUpgrades.txt'
alias fixBroken="eopkg check | grep Broken | awk '{print $4}' | xargs eopkg it --reinstall"
#
# System information
#
alias sysinfo='inxi -Fxxxza --no-host'
alias unitFiles="systemctl list-unit-files --state=enabled --no-pager"
#
# Backup & restore
#
alias bkup='restic backup -e "/home/jerry/VirtualBox VMs" -e /home/jerry/.thunderbird -e /home/jerry/.cache /home/jerry -r /mnt/Backups/Linux/hostname
'
alias pruneBkups='restic forget --keep-last 5 -r /mnt/Backups/Linux/hostname
'
alias backup='copyPackages && echo "Packages copied." && bkup && pruneBkups'
I left some additional things in these, that are not strictly related to doing a back and then installing an update, but I thought they might be useful, so why remove them? I thought it might be better just to document them. In the Related to updates section, the last two lines are ones you might have seen before. These are not specific to my system, so they should not need any changes in order to work with yours:
checkUpgrades - updates the Solus repository and lists any packages that have been upgraded since the last update you installed. Tells you whether a sync has been done.
fixBroken - checks the quality of your last update, and lists any packages that are broken, then attempts to reinstall those. I didn't write this last one, and if you want to know who did, a quick forum search should locate it.
Also, at the end of the System information section are a couple that might interest you.
sysinfo - uses inxi with the arguments needed to list your entire system.
unitFiles - list the unit files that are loaded and enabled during system startup, and disabled and unloaded upon shutdown. This macro has very little use on a Solus system, because it starts with very few (3 or 4, usually), and Solus starts up and shuts down amazingly fast. But when you examine other interesting distros, you might want to check them. I've seen around 70 - 80 many times, and even 152 once (for an early version of Ultramarine Plasma). Technically, these are not a perfect measure of startup and shutdown speed, but in my experience they provide a useful estimate of what can be expected from a distro and why.
Notes
Again, be sure to replace my user name (jerry)
with yours everywhere. If you use an editor with a search/replace feature, that will be easy. If you need to do it manually, go slow and do a complete job. But if you miss any, you'll simply get an error at runtime asking about jerry. So you'll quickly know what still needs fixing.
In the restic commands that require a -r
repository argument, mine use:
-r /mnt/Backups/Linux/hostname'
My backup location is the NAS share that's mounted on /mnt/Backups/Linux
and hostname
simply identifies the name of the device that's being backed up. I backup a number of computers here, so I need to be able to identify the one that each backup applies to. Even if you only backup one system, there's no need to change this. I just thought I would explain the syntax.
As I've mentioned earlier, the -e
arguments in the backup command simply identify things that are likely to be huge, and don't need to be backed up anyway, like caches that will be recreated as needed. Using these arguments saves backup and restore time, and also saves a lot of space in your backup respository. You can adjust or remove these if you have different needs, especially if you don't have any VBox virtual machines stored in your home directory.
The Related to updates section includes some commands to clean things up after a sync, and you can remove those arguments if you feel you don't need them, or you can just leave them, as they're harmless if they're not needed. For example, you may not currently use any flatpaks, but if you install some later on, you'll probably want the cleanup stuff for those. And if you never install any flatpaks, that command will do no harm.
Conclusion
This document may seem to be really long and complicated at first. It certainly took me a long time to write it. But remember, it's designed so that before every sync, all you need to do is:
backup
up
You could even combine those into one command to do it all, if you're even lazier than I am. But the point I'm making is that editing these scripts to fit your own requirements may take a little while, but it will provide a useful service that you can run before every sync with just those two commands.
Remember that testing the backup command after you've modified the script won't do any harm, even if the script may still need a little more work. Just test it as you make your changes, and correct any errors that might be reported. When you're finished, the last backup you did should be perfect. You can either delete the entire repository and create it again, or simply start using it. Any previous backups that required fixing will be pruned away as you create new backups.
If you have any questions as you modify these scripts for your own use, don't hesitate to ask me (WetGeek) for help in the Solus forum. Most days I check it frequently enough that you can expect a fairly quick answer.