You are not logged in.
*** USE AT YOUR OWN RISK AND NEVER ON A PRODUCTION SYSTEM ***
This is just an idea I have, and I'd like some input on it. There's a very good chance that it can break your system, so please be careful.
This method will (hopefully) allow you to restore your entire root drive with just one command: rysnc. Keep in mind that you'll likely have to adjust the parameters to suit your filesystem. I've put very little testing into this, so there may be horrid shortcomings that I'm not aware of! My tests involved removing/adding one simple file and also installing gnome aside kde and then restoring back to just kde. Both tests worked fine for me. Keep in mind that this will not make a backup of the current system. It will only sync the current system to the snapshot.
The whole thing is actually done while mounted on the bcachefs drive which you want to restore.
Note that you may need to reboot IMMEDIATELY after doing the sync or you may end up with some serious corruption and/or messed up files!
First make sure to close your browser as it'll tend to make several temporary files that can interrupt with this test.
Then test if it's working:
touch /oldfile
mkdir -p /.snapshots
bcachefs subvolume snapshot / /.snapshots/test
rm /oldfile
touch /newfile
Now do a dry run to see if /oldfile is restored and /newfile is deleted to make sure it's working. You'll know it's working if you see that /oldfile is being restored and /newfile is being deleted. Make sure that no other files have changed. If you see a huge list of changed files, this probably didn't work, and you'll need edit the command to suit your system better:
** Be mindful of /boot and /efi. If excluded improperly, rsync may simply delete them, assuming they don't exist since they're on separate partitions and not covered under the snapshots. Also make sure to exclude your snapshot directory! **
rsync --dry-run -av --del --exclude=/.snapshots/ --exclude=/dev/ --exclude=/proc/ --exclude=/sys/ --exclude=/tmp/ --exclude=/run/ --exclude=/mnt/ --exclude=/var/tmp/ --exclude=/var/log/ --exclude=/var/lib/systemd/random-seed --exclude=/root/.cache/* --exclude=/mnt/ --exclude=/boot/ --exclude=/efi/ /.snapshots/test/ /
If all looks well then do the rsync:
rsync -av --del --exclude=/.snapshots/ --exclude=/dev/ --exclude=/proc/ --exclude=/sys/ --exclude=/tmp/ --exclude=/run/ --exclude=/mnt/ --exclude=/var/tmp/ --exclude=/var/log/ --exclude=/var/lib/systemd/random-seed --exclude=/root/.cache/* --exclude=/mnt/ --exclude=/boot/ --exclude=/efi/ /.snapshots/test/ /
REBOOT IMMEDIATELY if important files have been changed!
You may now delete your snapshot subvolume if you'd like, since it's just the same as what's on your root drive anyways:
bcachefs subvolume delete /.snapshots/test
...
That's all I've got. I'm going to be using bcachefs as my main system and giving it a hard test, so I'll report back with any issues.
I'd appreciate any feedback.
Last edited by bedtime (2025-02-22 14:54:43)
Offline