> For the complete documentation index, see [llms.txt](https://my-learning-journey.devjugal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://my-learning-journey.devjugal.com/content/2024/august/day-08.md).

# August 08, 2024

## Things That I Discovered

### 1. **Take Out Full Backup of Raspberry Pi SD Card**

* I learned how to create a complete backup of my Raspberry Pi SD card. This will help me preserve all my data and settings before giving away the Raspberry Pi.
* **Reference**: [Backup Raspberry Pi SD Card](https://pimylifeup.com/backup-raspberry-pi/#backing-up-your-raspberry-pi-sd-card-on-linux)

### 2. **Backup Methods**

* **DD Command**: I discovered that using the `dd` command is a powerful way to clone the SD card.
  * Example command: `sudo dd if=/dev/sdX of=/path/to/backup.img bs=4M`
  * **Note**: Replace `/dev/sdX` with the actual device path of your SD card.
* **GUI Tools**: I found GUI tools like `Etcher` that simplify the backup process, making it easier for users who prefer not to use the command line.

### 3. **Exploring Content of Backup Image**

* Since, the image file contents all the partitions of the SD Card, we need calculate the offset for each partition and adjust accordingly. The offsets can be checked by `sudo fdisk -l` command.
* Example command: `sudo mount -o loop,offset=70254592 /path/to/backup-rpi-image.img /mnt/rpi-img`
  * **Note**: This command would mount the image file to `/mnt/rpi-img` directory, so create it beforehand!
* **Reference**: [Access the contents of a .img file](https://learn.pi-supply.com/make/access-the-contents-of-a-img-file/)

### 4. **Compressing Image File**

* Apparently, `dd` command would read and write even empty space to the image file, so we can just compress the image file using `gzip` command.
* Example command: `gzip --keep /path/to/backup-image.img`

### 5. **Importance of Regular Backups**

* I realized the significance of backing up not just the Raspberry Pi but also any critical data regularly. It’s a good practice to have multiple backup strategies.

## Reflections

* Today was productive! Understanding the backup process gives me peace of mind as I prepare to hand over my Raspberry Pi 4.
* I also appreciated how accessible these resources are; the online tutorials made it easy to follow along.
