Rebooting with a clean shutdown is fine. If you're just unplugging it then that is bad and you will corrupt the SD card itself or the filesystem.
The "SD Card Copier" utility if you're using the desktop version will do it. Otherwise use something like Win32DiskImager to create a backup. The backup will be the size of your card though so you'll need a lot of spare disk space to store it.
The Pi isn't doing anything wrong here. The Pi does use a journaled filesystem but it defaults to protecting metadata only. You can tell it to journal metadata + data but there is a performance penalty for doing that which is why Linux distributions don't have it enabled by default. Enabling it will ensure your filesystem is still consistent for data + metadata but you'll still lose any data that was in the cache and not written out yet. There is no 100% solution for this. You're just meant to not pull the plug without shutting down first.
If you have something that understands Ext4 like a Linux VM then you can mount the partition then backup the files only using tar, rsync or whatever your favourite backup tool is.dptdpt wrote: ↑Wed Jul 01, 2020 5:08 pmRegarding taking a backup - is there nothing that I can just back up the Pi filesystem, that only needs as much space as I'm using? Backing up and restoring the entire partition sounds time consuming and would use a lot of space. I'm looking for something I could use on a mac or PC, not on the pi itself...
No, there isn't, at that applies to *all* computers, not just Pis. What does exist are OSes that do very little writing by using a read-only root filesystem and running everything in RAM. But note that you're eventually going to have to save something somewhere or what's the point? That said, the data that gets saved doesn't have to get saved to the SD card. It could be saved to another device (such as a USB stick), or over a network connection to another system or device (Network Attached Storage or shared directory). But any time a system crashes or is taken down, anything left in caches will be lost and that may include directory structure data as well as applications or program data.
I use Win32DiskImager (which I also use to build SD cards in the first place). Yes, the file is the size of the card, and it takes a while. However, since I'm taking that backup to a 2TB HDD, space isn't an issue. And if space becomes and issue, I can always compress the files.dptdpt wrote: ↑Wed Jul 01, 2020 5:08 pmRegarding taking a backup - is there nothing that I can just back up the Pi filesystem, that only needs as much space as I'm using? Backing up and restoring the entire partition sounds time consuming and would use a lot of space. I'm looking for something I could use on a mac or PC, not on the pi itself...
Umm, that isn't true. Any copy-on-write filesystem -- such as ZFS or ButterFS -- will be consistent on disc at all times, although of course you may lose data that hasn't been completely committed to storage before the event (partially-commited data, such as that written to a journal but not written to its final resting place may be recovered on the next mount; that depends on the filesystem).W. H. Heydt wrote: ↑Wed Jul 01, 2020 6:20 pmNo, there isn't, at that applies to *all* computers, not just Pis.
Doesn't matter. By default the system flushes the disk cache every five seconds, in between it will do little or no writes.
Modern SDs are faster so maybe just less probability of being caught in the middle of a write.