Backup home for reinstall

What's better for restoring your home folder to a reinstall of bazzite A tar backup or a clonezilla backup? And then I just cp -a everything Which will preserve permissions better? Especially considering there are some root owned folders in my home (distrobox and waydroid) This is how I'm thinking of formatting the tar command
sudo tar -cvpf /mnt/DATA/homefolder.tar --xattrs --acls --selinux --numeric-owner -I "zstd -3" -C /var/home . >> tar-home log
sudo tar -cvpf /mnt/DATA/homefolder.tar --xattrs --acls --selinux --numeric-owner -I "zstd -3" -C /var/home . >> tar-home log
This should backup my home folder included the linuxbrew homebrew folder This way I keep all apps configs and files from my current bazzite install But I'm worried because even though this tar command is supposed to mantain permissions last time I tried something like this the sudo tar broke permissions See https://discord.com/channels/1072614816579063828/1273442214999097435
32 Replies
zany130
zany130OP3w ago
Welp this went as expected I ran
sudo tar -cvpf - \
--xattrs --acls --selinux --numeric-owner \
-C /var/home/zany130 \
--exclude='.steam' --exclude='.local/share/Steam' \
. > /mnt/DATA/homeminussteam.tar
sudo tar -cvpf - \
--xattrs --acls --selinux --numeric-owner \
-C /var/home/zany130 \
--exclude='.steam' --exclude='.local/share/Steam' \
. > /mnt/DATA/homeminussteam.tar
And restores with
sudo tar -xvpf /media/ubuntu/DATA/homeminussteam.tar \
--xattrs --acls --selinux --same-owner \
-C /media/ubuntu/bazzite-deck_fedora/home
sudo tar -xvpf /media/ubuntu/DATA/homeminussteam.tar \
--xattrs --acls --selinux --same-owner \
-C /media/ubuntu/bazzite-deck_fedora/home
And I know have a mix of broken permissions Some (but not all which is really weird) things are root owned when they should be usere owned And the main folders I wanted root owned waydroid and distrobox are user owned breaking distrobox and waydroid Is there no way to cleanly keep all my flatpaks .configs ect when reinstalling bazzite? Lucky I still have a clonezilla backup that has my home folder with the correct permissions
nagito || Knight of Emilia
keeping everything would probably result in the sane problem you had initially
mrvictorywin (Ping on reply)
rsync -aAXH --info=progress2 to answer your original question Oh and there is a selinux related flag but idr what it was
bazzite-lightyear
I'd love to see an official ublue-os best practice guide for this, as I've been wondering about the same thing. Ideally not only for the home directory, but also OS and app settings and data that might live elsewhere in /etc or /var.
mrvictorywin (Ping on reply)
rsync & tools based on it are the gold standard for this purpose. rsync can carry over the entire OS filesystem while preserving all permissons, leaving user only bootloader installation. The catch is bazzite uses selinux so moving files from a non selinux system to a selinux system (ie. Arch to Bazzite, what I did) creates some weird errors. I have done Arch to Arch and it works well.
zany130
zany130OP3w ago
Well my system boots right. Now with my messed up permissions home folder. Plasma loads and everything the only thing is permissions are messed up on some things like distrobox so that's not working but the system does boot and work I guess my best bet is grabbing the stuff with bad permission from my clonezilla backup and Rsync like that Only problem is a ztsd compromised my clonezilla backup so I can't just mount it
nagito || Knight of Emilia
oh wowie it's highly unlikely that the problem was system files originally though i don't exactly know how OSTree works i assume you did try rpm-ostree reset
zany130
zany130OP3w ago
It probably was the update I did corrupted something on the system Yeah I did try a reset
nagito || Knight of Emilia
that's the thing you updating shouldn't corrupt anything on the systen as it constructs a new system hence why updates mean a reboot
zany130
zany130OP3w ago
Something probably went wrong with the update the really strange part was my roll back image was borked too
nagito || Knight of Emilia
i wish OSTree was actually documented
zany130
zany130OP3w ago
And the way it broke was so strange too network manager wouldn't load so there was no internet and Kernel panics /bsod randomly I never had a Linux system so royally fucked up before
nagito || Knight of Emilia
i use Nix/Nix OS which OSTree is inspired by but Nix is more understandable yeah me neither only weird problem i've had on Nix OS is a single file somehow got incorrect permissions which prevented me from updating for a bit until i fixed it though it would have fixed itself if i just waited due to how Nix OS works it was very simple to fix i love explaining this concept basically Nix has this place called the Nix store in /nix/store every package file lives here this folder is read only most of the time unless you're telling Nix to build a package in which case an output folder is writable until the package is installed each output folder has an unique hash based on it's "inputs" inputs are it's dependencies including source code sha256 hashes of all the paths are recorded in Nix' database so corruption is simple to catch
mrvictorywin (Ping on reply)
haiku is even better
nagito || Knight of Emilia
store files are read only & executable
mrvictorywin (Ping on reply)
it saves all packages in a directory and instead of installing them, it mounts them at system bootup whole system is like 500 files
nagito || Knight of Emilia
Nix "installs" packages by symlinking their output folder to either the system "profile" or the user profile
mrvictorywin (Ping on reply)
user profile? on haiku package files are never extracted, they stay as packages
nagito || Knight of Emilia
yes the user profile is a location in your home folder/$PATH wher files get symlinked so that they could be found easily by your shell or DE or whatever
mrvictorywin (Ping on reply)
per user packages, interesting
nagito || Knight of Emilia
yup when you run say nix profile add nixpkgs#htop the nix program asks the Nix daemon running in the background to get that package for you hence why per user packages are allowed the nix binary by default doesn't touch the store directly though it cam of running as root so you don't NEED a daemon though for some reason currently you can't tell the daemon to repair the store so you have to run sudo nix store repair --all to fix all the paths in case of corruption be nice if tthe daemon could do this in the background Nix OS is just another package in the Nix store it's folder contains symlinks to all system files the equivalent of usr is system folder/sw here you'll find bin share lib & the rest there are also other un usual files in the system folder like one called init & another called kernel & an interesting one called boot.json init is as you'd expect a symlink to init & kernel is a symlink to the kernel boot.json is a json file containing the full non symlink paths to both of these as well as the kernel command line this is here for somebody who wants to add a bootloader backend though Nix OS already supports systemd-boot & grub each system folder has an activate script this is run at startup by the initrd to create the system sy,mlinks & (re) generate files in /etc though this script can do whatever you need to set up a system this script creates a symlink to the current active system in /run/current-system/ & /run/booted-system as you\d expect the current system symlink can be changed at runtime so booted system exists to lead you back to the original all user profile & system symlinks are accessible in /nix/var/nix/profile say you installed something to the system & it broke you can just run sudo /run/booted-system/bin/switch-to-configuration switch so goes for any other system the system can also be selected at boot from grub of course Nix cannot store suid binaries in the store so Nix OS uses /run/security/wrappers to store generated suid wrppers that run the original no suid binary in fact Nix doesn't store any special attributes on files in the store whereas OSTree does hence why SELinux works oh this might be what caused the problem maybe the syslinux file attributes got messed up & OSTree doesn't really look at them so it doesn't know there's anything wrong to fix
zany130
zany130OP3w ago
Something I just thought of Bazzite keeps /etc , /home, and /var On a separate partition What would happen if I used clonezilla to only restore that partition and keep the rest as is?
nagito || Knight of Emilia
donno though NetworkManager settings are stored in /etc
zany130
zany130OP3w ago
According to chatgpt it might break selinux
zany130
zany130OP3w ago
Yeah that to if the network manager config was somehow bad it would also copy that
nagito || Knight of Emilia
selinux attributes if not correct will cause problems that's the point of them
zany130
zany130OP3w ago
Yeah probably not worth it if anything I should mount the clonezilla backup a selectively copy over things I don't want to keep my etc either really
nagito || Knight of Emilia
to be an extra layer of security on top of regular permissions they can act as per process permissions by default apps run by you can access whatever you can with SELinux they can only access files that have the correct "context" for instance let's say you had a web server & some files for it to serve
zany130
zany130OP3w ago
It's just I was dumb and I zst compressed the clonezilla backup and it also split it into parts So I have to combine all the parts first . Uncompress that convert the file onto a mountable disk image and then I can mount it and copy things Clonezilla has a raw disk dump option that would of just spit out a disk image that I could mount should of done that And then copy over files with Rsync though I'm not sure if selinux would be intact
nagito || Knight of Emilia
you could limit the web server to only have access to files of the say www_file context & give those files that context & boom the server run by you root or anyone else can only touch those specific files not any of your or root's files & that is basically what SELinux does protect your files from possibly malicious/exploitable apps you run there is restorecon it restores the contexts of files based on where in the filesystem they are for instance a file in your home folder would gain the home_file context not sure if it's actually called home_file but it's something like that you can ls -Z ~ to see the contexts of files in your home folder
zany130
zany130OP3w ago
its so random what tar makes root owned and what it doesnt my steam folder was restored as root :ConfusedDog: but other folders in .local/share/got owned by user for example .local/share/applications is correctly user owned so its not even that its inverting ownership or making everything root it just randomly makes some folders root. and im pretty sure my steam folder wasn't root owned and then some folders that where supposed to be root owned got user owned but again not all some are correctly root owned like this backup i did of a applications settings in /etc/ its so random acthually arccording to chatgpt what might be happening is its restoreing .local/share/Steam/blah before the achtual .local/share/Steam folder since i deleted that folder beforing running the restore (in case of conflicts) it created that path and it created it with the running users permision (root) when it finally gets to the top level Steam folder it sees .local/Steam already exists and the default behavior is --no-overwrite-dir so it doesn't change the permisions to the one from the tar. the solution is to specfiy an order for extraction or enable overwritting dirctors with the copy in tar

Did you find this page helpful?