There are many questions on this site asking how to backup a Raspberry Pi.
The most important thing is to actually perform backups, and the faster and easier the process the better.
I have used the following 4 methods (although there are others)
1. Create a disk image
Advantages:
- This can be done (off-line) on any computer system (Windows, macOS or Linux) although the methods differ.
- Can backup any type of SD Card even NOOBS or other multi OS systems.
Disadvantages:
- The image files created are LARGE (as large as the SD Card) and contain useless data, although they generally compress well.
- The image can only be restored to a SD Card of the same size or larger. (Nominally identical cards often differ in size.)
How do I backup my Raspberry Pi?
2. rsync file copy
These techniques (there are many variants) performs a file by file copy retaining Linux attributes (links, permissions etc.).
Variants exist to copy a live system or an off-line SD Card.
Advantages:
- This only copies essential files (if properly configured) so makes smaller "images".
- The copy can be faster, especially if the previous backup is incrementally updated.
Disadvantages:
- The process CAN be slow (especially for large systems).
- The backup medium NEEDS to understand Linux file systems.
- The process does not retain partition information, so needs to be restored to a correctly formatted image.
https://raspberrypi.stackexchange.com/a/5492/8697 discusses this technique, and is recommended reading.
https://raspberrypi.stackexchange.com/a/28087/8697
3. SD Card Copier
This is a tool included in newer Raspbian images which copies a live OS to a SD Card.
This is a hybrid technique which creates an image then uses file copy to populate the image.
Advantages:
- Can copy to any size SD Card (larger or smaller - assuming the Card is large enough)
Disadvantages:
- Can be very slow as it performs a fresh copy each time, and file copy is inherently slower than block copy.
- Mainly applicable to conventional Raspbian images, although it can copy multi OS systems only the last partition size is adjusted.
- SD Card Copier seems to be intolerant of SD Card defects and works better with fresh cards.
4. Create an image of a running system
This is a hybrid technique which creates an image then uses rsync to populate the image.
It is useful for creating smaller images of a system or backup images which can easily be customised.
Advantages:
- Can create an image on any storage medium which allows large files and is supported by Pi e.g. ext4, exFAT or a network drive.
- Can create full size images, minimum size images or images of arbitrary size.
- Incremental backups are fast and simple.
Disadvantages:
- Only applicable to conventional 2 partition images e.g. Raspbian.
Backup image of SD Card
General Observations
There is a potential risk performing a backup of an active system, although the risk is small. Obviously you would not perform a backup during an upgrade or other process which is likely to require extensive filesystem changes. Most of these techniques can be adapted for off-line use.
Modern Linux systems utilise UUID (PARTUUID for Raspberry Pi systems) to identify partitions. It is a good idea to ensure each image has a unique PARTUUID and there are tools to perform this. (SD Card Copier has an option to perform on copy.)
There are a number of tools which can shrink an OS Image.