# Blog Backup Best Practices

**Last Updated:** 2026-01-10

> **Superseded for strategy and day-to-day commands:** Use **[guides/BACKUP_GUIDE.md](guides/BACKUP_GUIDE.md)** as the canonical blog backup doc (Git vs local snapshots, when to snapshot, improvement pipeline, retention). This file remains as supplementary detail.

Best practices for blog backups, including when to create backups, frequency recommendations, and validation checklists.

## When to Create Backups

### Before Major Changes

Always create a backup before:

- Bulk content updates
- Content migration steps
- Template changes
- Schema modifications
- Link structure changes

### After Significant Updates

Create backups after:

- Content imports
- Major content edits
- Link additions/removals
- SEO updates
- Image updates

### Regular Schedule

Create backups:

- Daily (automated) during active development
- Weekly during stable periods
- Monthly for long-term archiving
- Before deployments

## Backup Frequency Recommendations

### Development Phase

**Frequency:** Daily

**Rationale:**

- Frequent content changes
- Higher risk of errors
- Need quick recovery

**Setup:** Automated daily backups

### Stable Phase

**Frequency:** Weekly

**Rationale:**

- Less frequent changes
- Lower risk
- Sufficient recovery point

**Setup:** Automated weekly backups

### Production Phase

**Frequency:** Daily + On-demand

**Rationale:**

- Critical content
- Need recent recovery points
- Before major changes

**Setup:** Automated daily + manual before changes

## Validation Checklist

### Before Creating Backup

- [ ] Source files exist and are accessible
- [ ] Sufficient disk space available
- [ ] Backup script executable
- [ ] Write permissions to backup directory

### After Creating Backup

- [ ] Backup directory created
- [ ] Manifest file present
- [ ] All expected files present
- [ ] JSON files valid (no syntax errors)
- [ ] File counts match source
- [ ] Checksums calculated

### Before Restoration

- [ ] Backup validated successfully
- [ ] Source backup location verified
- [ ] Target directory writable
- [ ] Current content backed up (if needed)
- [ ] Restoration script tested (dry run)

### After Restoration

- [ ] All files restored
- [ ] File counts match backup
- [ ] JSON files valid
- [ ] Content loads correctly
- [ ] No errors in restoration report

## Backup Validation

### Quick Validation

```bash
python3 scripts/blog/validate-backup.py <backup_directory>
```

Checks:

- JSON syntax
- File completeness
- Checksums

### Full Validation

```bash
python3 scripts/blog/check-backup-integrity.py <backup_directory>
```

Checks:

- File counts match
- Checksums match source
- No missing files
- No corrupted files

### Status Check

```bash
python3 scripts/blog/check-backup-status.py
```

Shows:

- Recent backups
- Backup health
- WordPress backup status

## Backup Storage

### Local Storage

**Location:** `docs/backups/`

**Advantages:**

- Fast access
- No network dependency
- Version controlled (if committed)

**Considerations:**

- Disk space
- Backup retention
- Local only

### Archive Storage

**Location:** `docs/backups/archive/`

**Purpose:**

- Long-term storage
- Old backups
- Compliance

**Management:**

- Automatic archiving
- Manual review
- Periodic cleanup

## Restoration Testing

### Regular Testing

Test restoration:

- Monthly (automated backups)
- Before major changes
- After backup creation
- Quarterly (full restoration test)

### Test Procedure

1. Create test backup
2. Restore to test directory
3. Validate restored content
4. Compare with source
5. Document results

### Dry Run Testing

Always test with dry run first:

```bash
python3 scripts/blog/restore-from-snapshot.py <backup> --dry-run
```

## Backup Documentation

### Document Each Backup

Include:

- Backup date and time
- Backup purpose
- Trigger (manual/automated)
- Post count
- Notes

### Track Restoration History

Document:

- Restoration date
- Source backup
- Reason for restoration
- Results
- Issues encountered

### Maintain Backup Index

Update [guides/BACKUP_INDEX.md](guides/BACKUP_INDEX.md) (optional) with:

- Backup dates
- Backup types
- Locations
- Purposes
- Restoration notes

## Error Handling

### Backup Failures

**Actions:**

1. Check error logs
2. Verify source files
3. Check disk space
4. Retry backup
5. Document issue

### Validation Failures

**Actions:**

1. Review validation report
2. Check file integrity
3. Re-create backup if needed
4. Document issue

### Restoration Failures

**Actions:**

1. Validate backup first
2. Check target permissions
3. Review restoration report
4. Try alternative backup
5. Document issue

## Security Considerations

### Backup Access

- Limit access to backup directory
- Use appropriate file permissions
- Protect backup manifests
- Secure backup scripts

### Backup Integrity

- Verify checksums
- Validate JSON files
- Test restoration
- Monitor backup health

### Backup Retention

- Follow retention policy
- Archive old backups
- Secure archived backups
- Document retention periods

## Performance Considerations

### Backup Size

Monitor backup sizes:

- Post files: ~100KB each (99 posts = ~10MB)
- Supporting files: ~1MB
- Extraction data: ~50MB
- Total: ~60MB per backup

### Backup Duration

Typical durations:

- Snapshot backup: 5-10 seconds
- WordPress backup: 2-3 minutes (extraction)
- Validation: 1-2 seconds
- Restoration: 5-10 seconds

### Disk Space

Plan for:

- 30 daily backups: ~2GB
- 12 weekly backups: ~720MB
- 12 monthly backups: ~720MB
- Archive: Variable

Total: ~3.5GB + archive

## Related Documentation

- [Backup Guide](content/blog/BACKUP_GUIDE.md) - Complete backup guide
- [Backup Process](BACKUP_PROCESS.md) - Detailed procedures
- [WordPress Backup](WORDPRESS_BACKUP.md) - WordPress backup details
