My question is whether I can use the following command to create a SD card clone on the Raspberry Pi itself.
sudo dd bs=4M if=/dev/mmcblk0 of=raspbian-5.15.16.img
This can then be copied to my home PC was what I was thinking.
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.
Sign up to join this communityMy question is whether I can use the following command to create a SD card clone on the Raspberry Pi itself.
sudo dd bs=4M if=/dev/mmcblk0 of=raspbian-5.15.16.img
This can then be copied to my home PC was what I was thinking.
Yes you can, ... but it will almost certainly be inconsistent and not work as intended.
Any subsequent change to a sector already written will be lost which will leave the underlying file system in an unknown state. Perhaps a file has been moved or deleted and the sector is now in use by another file.
For a safer solution (if you are using Raspbian) see https://www.raspberrypi.org/blog/another-update-raspbian/ and search for "SD card copier".
One query which comes up a lot on the forums is about the best way to back up your Pi. People also want to know how to migrate their Raspbian install to a new SD card which is larger or smaller than the one they are using at the moment. This has been difficult with the command-line tools that we’ve recommended in the past, so there is now a new application to help with this, and you’ll find it in the menu under ‘Accessories’.
Yes and No. You can image on the Pi itself (although this may not be the best option), BUT you need to image to some external medium.
This can be a SD Card (in a USB adaptor) a HDD or network drive.
The command above would attempt to image the Pi to a file on the SD which will fail.
The latest Raspbian has a SD Copy utility (which I have not used).
Use the package piclone. It will copy the current running system to SD which can then be backed up to your PC using win32diskimager.
Hint: remove as much stuff that you don't use in the running image as possible to get the backup file size small. Use as small an SD that you can to keep your back up files small, also reducing image read and write in the future.
Hint 2: expand the partition on any backup SD cards as this isn't automatic.