Backing up means saving copies of your important files so you don't lose them. Recovery means using those copies to get your files back if something goes wrong.
Backup and recovery strategies in Raspberry Pi
rsync -av --delete /source/directory/ /backup/directory/ # or using dd to copy SD card: sudo dd if=/dev/mmcblk0 of=/path/to/backup.img bs=4M status=progress
rsync copies files and keeps them updated between folders.
dd makes a full image copy of your SD card for complete backup.
rsync -av /home/pi/projects/ /media/usb/backup_projects/
sudo dd if=/dev/mmcblk0 of=/home/pi/backup.img bs=4M status=progress
rsync -av --delete /home/pi/ /media/usb/backup_pi/
This script copies your projects folder to a USB backup folder. It creates the backup folder if needed and shows a message when done.
#!/bin/bash # Simple backup script for Raspberry Pi SOURCE_DIR="/home/pi/projects" BACKUP_DIR="/media/usb/backup_projects" # Create backup directory if it doesn't exist mkdir -p "$BACKUP_DIR" # Run rsync to copy files rsync -av --delete "$SOURCE_DIR/" "$BACKUP_DIR/" echo "Backup completed from $SOURCE_DIR to $BACKUP_DIR"
Always test your backups by restoring some files to make sure they work.
Use external drives or cloud storage to keep backups safe from hardware failure.
Schedule regular backups using cron jobs to automate the process.
Backup saves copies of your important files to protect against loss.
Recovery uses backups to restore your files or system after problems.
Use tools like rsync for file backups and dd for full SD card images.
Practice
Solution
Step 1: Understand the concept of backup
Backups are copies of important data saved separately to prevent loss.Step 2: Identify the main purpose on Raspberry Pi
On Raspberry Pi, backups protect files from accidental deletion or corruption.Final Answer:
To save copies of important files in case of data loss -> Option CQuick Check:
Backup = Save copies [OK]
- Confusing backup with speeding up the device
- Thinking backup installs software
- Assuming backup changes display settings
Solution
Step 1: Identify commands for backup
rsync copies files, dd creates exact disk images, cp copies files, mv moves files.Step 2: Choose command for full SD card image
dd is used to create a full image backup of the SD card on Raspberry Pi.Final Answer:
dd -> Option BQuick Check:
Full image backup = dd [OK]
- Using rsync for full disk image instead of file sync
- Confusing cp or mv with disk imaging
- Not knowing dd creates exact disk copies
rsync -av --delete /home/pi/data/ /backup/data/
Solution
Step 1: Understand rsync options
-a means archive (copy recursively with attributes), -v means verbose, --delete removes files in destination not in source.Step 2: Analyze source and destination paths
Files are copied from /home/pi/data/ to /backup/data/ with deletion of extra files in destination.Final Answer:
Copies files from /home/pi/data/ to /backup/data/ and deletes files not in source -> Option AQuick Check:
rsync -av --delete = sync with deletion [OK]
- Confusing source and destination order
- Thinking rsync moves files instead of copying
- Ignoring --delete option effect
dd if=/dev/mmcblk0 of=backup.img but get a 'Permission denied' error. What is the likely fix?Solution
Step 1: Understand permission error cause
Accessing /dev/mmcblk0 requires admin rights, normal user lacks permission.Step 2: Fix by running with elevated rights
Using sudo runs the command as admin, allowing access to device files.Final Answer:
Run the command with sudo to get admin rights -> Option AQuick Check:
Permission denied = need sudo [OK]
- Changing file extension does not fix permission
- Switching to rsync won't fix device access
- Restarting doesn't change permissions
Solution
Step 1: Identify automation tools on Raspberry Pi
rsync efficiently copies files; cron schedules tasks automatically.Step 2: Choose best method for daily automated backup
Writing a script with rsync and scheduling with cron automates daily backups reliably.Final Answer:
Write a script using rsync and schedule it with cron -> Option DQuick Check:
Automate backups = rsync + cron [OK]
- Relying on manual copying is not automated
- Using dd hourly wastes space and time
- Installing unrelated software won't backup files
Ready to prove it?
Pass the test and this pattern moves unknown
