174
submitted 9 months ago by summerof69@lemm.ee to c/selfhosted@lemmy.world

I recently decided to replace the SD card in my Raspberry Pi and reinstall the system. Without any special backups in place, I turned to rsync to duplicate /var/lib/docker with all my containers, including Nextcloud.

Step #1: I mounted an external hard drive to /mnt/temp.

Step #2: I used rsync to copy the data to /mnt/tmp. See the difference?

Step #3: I reformatted the SD card.

Step #4: I realized my mistake.

Moral: no one is immune to their own stupidity 😂

top 50 comments
sorted by: hot top controversial new old
[-] Nibodhika@lemmy.world 84 points 9 months ago

If you have one backup, you have no backup. That's a hard lesson to learn, but if you care about those photos it's possible to recover them if you haven't written stuff on that sdcard yet.

[-] TWeaK@lemm.ee 35 points 9 months ago

At least 3 backups, 2 different media, 1 offsite location.

[-] krash@lemmy.ml 8 points 9 months ago* (last edited 9 months ago)

I like 3-2-1-1-0 better. Like yours, but:

  • the additional 1 is for "offline" (so you have one offsite and offline backup copy).
  • 0 for zero errors. Backups must be tested and verified.
[-] xlash123@sh.itjust.works 6 points 9 months ago

Also, if you haven't tried to restore from backup, you have no backup.

[-] space@lemmy.dbzer0.com 43 points 9 months ago* (last edited 9 months ago)

Fuck up #1: no backups

Fuck up #2: using SD cards for data storage. SD cards and USB drives are ephemeral storage devices, not to be relied on. Most of the time they use file systems like FAT32 which are far less safe than NTFS or ext4. Use reliable storage media, like hard drives.

Fuck up #3: no backups.

load more comments (11 replies)
[-] ducking_donuts@lemm.ee 29 points 9 months ago

Unless you’ve used something secure for formatting or wrote data to the SD after, consider attempting data recovery.

[-] summerof69@lemm.ee 11 points 9 months ago

No luck with extundelete (segfault) and testdisk (sees some deleted files, but not /var/lib/docker). At least I can always throws it away and not worry about safety of my data! :)

[-] Nilz@sopuli.xyz 16 points 9 months ago

You can always try professional data recovery services. It just depends on how much the data is worth to you.

load more comments (1 replies)
[-] MangoPenguin@lemmy.blahaj.zone 28 points 9 months ago* (last edited 9 months ago)

I'm just impressed an SD card in a Pi lasted since 2017 without losing all your data on its own.

For the future the general guideline is 3 copies of your data at minimum, so definitely set up some backups.

[-] AceBonobo@lemmy.world 2 points 9 months ago

How do you actually do that?

[-] MangoPenguin@lemmy.blahaj.zone 2 points 9 months ago

Lots of backup software out there, I use a mix of Veeam Endpoint, Restic w/ Backblaze B2, and iDrive.

[-] xlash123@sh.itjust.works 23 points 9 months ago* (last edited 9 months ago)

If you haven't done much writing to the SD card, you may be able to recover the data. Data isn't really "deleted", it is just labeled as deleted. There is software that can comb through the raw data and try to make sense of what files were there. I don't know of any specific software, so if anyone knows, please reply

Edit: Another commenter mentioned some success with DMDE

Edit 2: Worth mentioning that this is true of formats. As long as it doesn't zero out the entire media, it just edits the file system metadata to say there are no files.

[-] space@lemmy.dbzer0.com 11 points 9 months ago

PhotoRec and TestDisk are probably the best, but they don't recover file structure.

[-] outcide@lemmy.world 21 points 9 months ago

There's an old saying, "Unix is user friendly, it's just fussy about it's friends."

[-] lando55@lemmy.world 7 points 9 months ago

Unix is the kind of friend who won't bat an eye about holding your beer while you go and do something incredibly stupid

[-] turkalino@lemmy.yachts 20 points 9 months ago

Everyone else is gonna be like "if you don't have at least 3 backups of something blahblah" but you know, not everyone has the finances for that, so advice from a cheapskate computer nerd: when going through critical transfers/reformats/deletions like you were doing, ALWAYS try actually recovering stuff from the backup before you cross the point of no return. E.g. if the backup is a .zip, extract a few individual files from it and open them in their respective programs.

[-] bruhduh@lemmy.world 19 points 9 months ago* (last edited 9 months ago)

Testdisk and photorec, use them, they even saved my data from bricked Chinese usb flash drive, so it'll save yours unless you wrote dd if /dev/zero of /*/microsd. Also here's the tip, don't attempt to rebuild partition firstly, first step try to copy all files from microsd to another device with these programs and after that try other ways, edit: I've seen from your other comments that your data already was overwritten, my condolences

[-] notsofunnycomment@mander.xyz 14 points 9 months ago

Condolences

[-] Geth@lemmy.dbzer0.com 13 points 9 months ago

I know I'm going to get down voted for this but this would be almost impossible to fuck up with a gui. Yet people insist that writing commands manually is superior. I'm sorry for your loss.

[-] jkrtn@lemmy.ml 6 points 9 months ago

Guardrails are absolutely not a reason why people prefer the CLI. We want the guardrails off so we can go faster.

[-] Geth@lemmy.dbzer0.com 3 points 9 months ago

This is on me for sure that I've never seen anyone be faster using a CLI compared to a GUI especially for basic operations which is what most of us do 95% of the time. I know there are specific cases where a command just does it better/easier but for me that's not the case for everyday stuff.

[-] Cyber@feddit.uk 3 points 9 months ago* (last edited 9 months ago)

But what about the movies where the actors are typing commands and a visual GUI is moving around and updating on the screen (and making sound effects too).

Isn't that the best of all worlds? /s

[-] wargreymon2023@sopuli.xyz 6 points 9 months ago* (last edited 9 months ago)

Fair enough.

CLI is not about ease to begin with, it is about versatility.

[-] atzanteol@sh.itjust.works 5 points 9 months ago

There is something to be said about CLI applications being risky by default ("rm" doesn't prompt to ask, rsync --delete will do just that). But I've definitely slipped on the mouse button while "drag & dropping" files in a GUI before. And it can be a right mess if you move a bunch of individual files rather than a sub-folder...

load more comments (1 replies)
[-] lhamil64@programming.dev 2 points 9 months ago

To play devil's advocate, tab completion would have also likely caught this. OP could have typed /mnt/t and it would autofill temp, or would show the matching options if it's ambiguous.

[-] glasgitarrewelt@feddit.de 11 points 9 months ago* (last edited 9 months ago)

Sorry to hear, I feel you:

I wanted to delete all .m3u-files in my music collection when I learned:

find ./ -name "*.m3u" -delete -> this would have been the right way, all .m3u in the current folder would have been deleted.

find ./ -delete -name "*.m3u" -> WRONG, this just deletes the current folder and everything in it.

Who would have known, that the position of -delete actually matters.

[-] iknowitwheniseeit@lemmynsfw.com 6 points 9 months ago

I didn't know there was a -delete option to find! I've been piping to xargs -0 for decades!

[-] derpgon@programming.dev 5 points 9 months ago

Probably because it's easier to fuck up. With piping to xargs, you are forced to put the delete command last.

load more comments (1 replies)
[-] synapse1278@lemmy.world 5 points 9 months ago

I did this sort of mistakes too, luckily BTRFS snapshots are always here to save the day !

[-] blackbirdbiryani@lemmy.world 2 points 9 months ago

I use GNU find every day and still have to google about the details. Only learnt about - delete the other day, good to know the position matters.

I can recommend fd to everyone frustrated with find, it has a much more intuitive interface imo, and it's also significantly faster.

load more comments (3 replies)
[-] BCsven@lemmy.ca 7 points 9 months ago

Unlesa you did a full zeroing format the info might still be available. There was an applicarion that attempts to rebuild the partition / Filesystem from left over meta data or inode info. I forget the name unfortunately. Normall the strings command will get your photos but probably not if they were in a docker image database.

[-] pHr34kY@lemmy.world 9 points 9 months ago

Testdisk and photorec? It's saved me heaps of times.

[-] BCsven@lemmy.ca 3 points 9 months ago

Those are good for sure. And maybe it was testdisk. There was one that just undeleted the partition table delete. as long as new data had not been written everthing would be intact

[-] kandoh@reddthat.com 6 points 9 months ago

The bells of the Gion monastery in India echo with the warning that all things are impermanent.

[-] shadowbert@kbin.social 6 points 9 months ago

My condolences :'(

I once lost a bunch of data because I accidently left a / at the end of a path... rsync can be dangerous lol

[-] blackbirdbiryani@lemmy.world 2 points 9 months ago

Rclone is superior IMHO, you have to explicitly name the output folder. Used to think it was a hassle but in hindsight being explicit about the destination reduces mistakes.

[-] shadowbert@kbin.social 2 points 8 months ago

Sometimes you're hands are tied by the tools already on the server - but I'll try to remember to check to see if that's available next time.

[-] vsis@feddit.cl 5 points 9 months ago

Sorry to read that.

I've dded an external drive instead of an SD card once by mistake. I've never felt more stupid than that day.

[-] KrapKake@lemmy.world 3 points 9 months ago

Classic Disk Destroyer moment.

[-] TORFdot0@lemmy.world 4 points 9 months ago

I think everyone has done this. I know I have. I believe I used dmda to recover all my photos back. Unfortunately I lost all the metadata for about 3000 photos. It took years to manually retap and redate them all but at least I didn’t lose them forever

load more comments (1 replies)
[-] bartolomeo@suppo.fi 3 points 9 months ago

Oh man, even reading that hurt ':D I'm sorry for your loss.

[-] possiblylinux127@lemmy.zip 2 points 9 months ago

You are probably out of luck. If you are lucky you can use gparted to recover deleted partitions

load more comments
view more: next ›
this post was submitted on 21 Feb 2024
174 points (95.8% liked)

Selfhosted

40347 readers
196 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS