Backup Scripts
linux
foundations
automation
backup
Creating automated backup procedures for critical data
Backup Scripts
Scenario: Developer Data Backup Automation
Company: xFusionCorp Industries
Task: Create automated backup for developer data
π§ Backup Strategy Fundamentals
Every system needs reliable backups. A good backup strategy includes:
The 3-2-1 Rule
- 3 copies of data
- 2 different storage types
- 1 offsite location
Backup Types
| Type | Description | Frequency |
|---|---|---|
| Full | Complete backup | Weekly |
| Incremental | Changes since last backup | Daily |
| Differential | Changes since last full | Daily |
π οΈ Implementation
Step 1: Create Backup Directory
mkdir -p /backup
chmod 700 /backupStep 2: Create Backup Script
#!/bin/bash
# backup.sh
DATE=$(date +%Y%m%d_%H%M%S)
SOURCE="/home/developer"
DEST="/backup/developer_$DATE.tar.gz"
# Create backup
tar -czf $DEST $SOURCE
# Verify
if [ $? -eq 0 ]; then
echo "Backup successful: $DEST"
else
echo "Backup failed"
exit 1
fiStep 3: Make Executable and Test
chmod +x backup.sh
./backup.shβ Verification
π― Key Learnings
- Backup automation
- Tar compression
- Error handling
- Cron integration
β Status
COMPLETED π
- Date: 2026-01-31