indi-allsky on a Raspberry Pi system regularly writes data (logs, databases, images, videos).
microSD cards are only designed for this to a limited extent and can fail without warning in the worst case.
A 1:1 backup of the entire SD card is possible in an emergency:
- Insert a new microSD card
- Restore the backup
- System starts exactly in the previous state
What is backed up in this guide?
The procedure described here creates a complete, bootable image of the SD card including:
- Bootloader
- partition table
- operating system
- Installed software
- configurations
- Data (e.g. indi-allsky, images, videos)
This is not a file backup, but a block-level image.
Requirements
Raspberry Pi is accessible via network
SSH access available
Backup is started from another computer (Linux, macOS, Windows with WSL)
Sufficient free disk space on the backup computer
Step 1: Check SSH access to the Raspberry Pi
From the backup computer:
ssh pi@<IP-ADRESS-DES-PI>
If the login works, you can start the backup.
Step 2: Identify the SD card on the Raspberry Pi
On the Raspberry Pi:
lsblk
Typical output:
mmcblk0 59.5G ├─mmcblk0p1 256M └─mmcblk0p2 59.2G
The entire device is important:
/dev/mmcblk0
Do not back up individual partitions.
Step 3: Stop writing services briefly (recommended)
If applications are running that are actively writing (e.g. indi-allsky, databases, camera software), these should be stopped briefly.
Example for indi-allsky (classic installation):
systemctl --user stop indi-allsky.service 2>/dev/null || true systemctl --user stop gunicorn-indi-allsky.socket 2>/dev/null || true systemctl --user stop gunicorn-indi-allsky.service 2>/dev/null || true systemctl --user stop indiserver.service 2>/dev/null || true systemctl --user stop indi-allsky.timer 2>/dev/null || true systemctl --user stop indiserver.timer 2>/dev/null || true
This ensures a consistent backup.
Step 4: Create a complete backup via SSH
The actual backup command is executed on the backup computer:
ssh pi@<IP-ADRESS-DES-PI> \ "sudo dd if=/dev/mmcblk0 bs=4M status=progress" \ | gzip > raspberry-backup-$(date +%F).img.gz
What happens in the process:
- dd reads the complete SD card raw
- Data is transferred via SSH
- Backup is stored locally compressed
- Empty storage space is greatly reduced
Depending on the card size, the process takes a few minutes.
Important: A complete image is created – it is not possible to skip individual directories, for example.
Step 5: Restart services
Once the backup is complete, the previously stopped services can be restarted
or alternatively the Raspberry Pi can be rebooted:
sudo reboot
Where is the backup saved?
The backup is saved on the computer on which the command was executed, not on the Raspberry Pi.
The backup is located in the current working directory, e.g:
~/raspberry-backup-2025-01-07.img.gz
Restoration in an emergency
If the SD card is defective:
- Insert a new microSD card into the backup computer
- Restore the backup:
gzip -dc raspberry-backup-2025-01-07.img.gz \ | sudo dd of=/dev/mmcblk0 bs=4M status=progress sync
- Insert the microSD card into the Raspberry Pi
- Start
The system then runs exactly as it did at the time of the backup
Avoid typical errors
- Do not save a backup on the same microSD card
- Do not just back up individual partitions
- Always check the target device carefully when restoring
- Restore the backup at least once as a test