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 😂

  • @[email protected]
    link
    fedilink
    English
    11
    edit-2
    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
      link
      English
      69 months ago

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

    • Synapse
      link
      fedilink
      English
      59 months ago

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

    • @[email protected]
      link
      fedilink
      English
      29 months ago

      The first one would have deleted nothing as it needs to match the whole name. I recommend running find with an explicit -print before replacing it in place with -delete or -exec. It’s good to remember that find has a complex order dependent language with -or and -and, but not maybe the best idea to try to use those features.

    • @[email protected]
      link
      fedilink
      English
      29 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.

    • @[email protected]
      link
      fedilink
      English
      29 months ago

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