Well I’ve joined the “accidentally trashing your system with rm -rf” club! Luckily I didn’t delete my home directory with all the things I care about, but I did delete /boot and /usr, and maybe /var (long story, boils down to me trying to delete non-system directories named those but reflexively adding the slash in front when I should not have). I have backups of those as well, so what are my prospects of recovering from this by just copying them back in using a live USB? Only issue is they’re stored in my server as belonging to the server user (I assume everything in those directories should belong to root and I can just use chown?) But I also don’t know if they retain the same permissions when backed up.

Has anyone had any luck recovering a system in this way? I’m hoping not to have to reinstall everything because I had gotten pretty cozy with the current installation.

UPDATE: I finally had the time to sit down and try it, and, I was at least hoping to document some glitchy or unstable behaviour but it just didn’t work at all. No matter what I tried I couldn’t even get the UEFI to recognize the old system as bootable, so I cut my losses and just reinstalled. Gonna make sure I have btrfs snapshotting enabled this time, which I’m realizing I probably should have done in the first place.

  • gomp@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    Just reinstall :)

    Copying back the files to the right partition/directory works, but if you didn’t backup the owner and permissions for each file it’s gonna be a pain to restore those.

    After reinstalling, you can compare your new system with your backup to see what changes/configs you had made

  • Holzkohlen@feddit.de
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Use dd next. Go for a trash your install speedrun! Hey, it’s the quickest way to learn 🤷‍♂️

  • redxef@feddit.de
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Is anything keeping you from just reinstalling the system and mounting your home into it again (maybe the majority of your customisations live in /home too)? I feel that is a lot less of a hassle than copying files around.

    In principle you should be able to restore your system by just copying all of the relevant files from the backup to their correct partitions - it can’t really get any worse if it doesn’t work.

    For the future: A backup is only any good if you know how to restore it and tested that that actually works.

    Regarding the permissions: If you do a cp fileA.txt fileB.txt fileB.txt will normally be owned by the creating user. So a sudo cp ... will create the files as root.

    I would personally use rsync with a few additional options, archive among them. This way the fs is restored exactly as it was. But that doesn’t make a whole lot of sense if the files weren’t copied that way too.

  • sebsch@discuss.tchncs.de
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    Normally its better practice to have the server configuration stored in a declarative way like ansible or similar and only store the userdata in the backup.

    So you can fast and easy reinstall your server including all of its config files and then clone the usage data like dbs or files into the new machine. This is more reliable and also faster than just do a full dump of the system.

  • bertmacho@lemm.ee
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    you dont say the o/s but if the pkg manager works, or you can add a statically compiled version, you could force reinstall all pkgs

  • Scott@lem.free.as
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    Yes but it’s hard work.

    I did it from the other side of the planet. I accidentally ran an rm -rf ... command on a running system. Luckily I had an identical system running that I could use to copy over the files, devices, etc.

    Learning about inodes and /proc/xxx/fd works, I was able to recover enough files to then copy over the rest from the other system.

    Doing it over SSH from the other side of the world was a tough 14 hours.