This project is a fully automated cloud-backup and disaster-recovery system designed to protect a static website and supporting files using Backblaze B2 Cloud Storage, Flask, and Python automation scripts.
It provides:
- Automatic scheduled backups
- Instant disaster simulation
- One-click website restoration
- Real-time monitoring dashboard
- GitHub Pages hosting for the public website (/docs)
- A persistent /admin control panel that cannot be deleted
- Project Overview
- System Architecture
- Project Structure
- Features
- Technologies Used
- Setup Instructions
- Environment Variables
- Running the Project
- Backup Workflow
- Disaster Simulation
- Restore Workflow
- Monitoring & Logging
- GitHub Pages Deployment
- Admin Control Panel
- Future Improvements
- Conclusion
This project solves a real-world problem:
β‘ what happens if your website files are accidentally deleted or corrupted?
To ensure your website always recovers, this system automatically:
- Backs up `/docs(website) to Backblaze B2
- Monitors backup status and logs it
- Provides a web interface to simulate disaster and recover files instantly
- Restores the site from B2 on demand and redeploys via
git push
It is fully automated and runs as a scheduled background job.
Here are key views of the automated backup and recovery system in action:
| Admin Control Panel | Live Content Editing |
|---|---|
![]() |
![]() |
| Website Homepage | Restore After Disaster |
![]() |
![]() |
βββββββββββββββββββββββββββββ
β GitHub Pages β
β Hosts the /docs website β
ββββββββββββββββ¬βββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββ
β Local App β
β Flask + Python Scripts β
ββββββββββββββββ¬βββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββ
β Admin Dashboard β
β /admin (never deleted) β
ββββββββββββββββ¬βββββββββββββ
β
ββββββββββββββββΌβββββββββββββ
β Automated Backup Scripts β
β backup_to_b2.py β
β restore_from_b2.py β
β disaster_recovery.py β
ββββββββββββββββ¬βββββββββββββ
β
βΌ
Cloud Storage
Backblaze B2 Bucket
automated-cloud-backup/
β
βββ docs/ # Public website served by GitHub Pages
β βββ index.html
β βββ about.html
β βββ contact.html
β βββ css/
β βββ js/
β βββ data/
β
βββ server.py # Flask web server + Admin dashboard
βββ backup_to_b2.py # Uploads latest backup to Backblaze B2
βββ restore_from_b2.py # Restores from cloud backup
βββ disaster_recovery.py # Deletes docs/ to simulate disaster
βββ monitor_backups.py # Logs backup status & timestamps
βββ metrics.json # Stores backup metrics
βββ backup.log # Log file for monitoring
β
βββ requirements.txt # Python dependencies
βββ .env # API keys (ignored in Git)
βββ README.md # Project documentationAutomatically zips the /docs folder and uploads it to Backblaze B2.
One-click "β Simulate Disaster" deletes the entire website folder.
One-click "π Restore Website" downloads the backup and recreates the website.
Accessible at: http://localhost:5000/admin
Shows:
- Last backup time
- Backup status
- Restore button
- Disaster simulation button
- Backup logs
Using Windows Task Scheduler / Cron.
Stores logs in:
backup.logmetrics.json
The /docs folder is served publicly via:
https://nidhi-shree.github.io/automated-cloud-backup/
The site now loads visible text from docs/data/content.json. A floating toolbar is available on every page:
- Edit Mode: toggles inline editing of content
- Save Changes: writes your edits back to
docs/data/content.json. - Backup: triggers automatic backup to Backblaze B2
- Restore: triggers restore from Backblaze B2
- Simulate Disaster: copies a command to delete
docs/locally (demo)
How saving works:
- The site saves changes via the Flask backend to
docs/data/content.json. - Saving automatically triggers a backup to Backblaze B2.
- Either way, the updated
content.jsonis a normal file insidedocs/and is included in backups.
Data format (docs/data/content.json):
{
"title": "Disaster Recovery Dashboard",
"tagline": "Automated Cloud Backup & Recovery Demo",
"about": "This project demonstrates how to automatically back up and restore a website using Backblaze B2 and GitHub Pages.",
"features": [
{ "title": "Automatic Backup", "description": "All site files are synced to Backblaze B2 cloud storage." },
{ "title": "One-Click Restore", "description": "Recover from simulated disasters instantly." },
{ "title": "Editable Frontend", "description": "Edit website content directly from your browser." }
],
"contact": {
"email": "demo@example.com",
"message": "Contact us to learn more about automated disaster recovery systems."
}
}# 1. Clone and install
git clone <repository-url>
cd automated-cloud-backup
pip install -r requirements.txt
# 2. Configure environment
cp env.example .env
# Edit .env with your Backblaze B2 credentials
# 3. Start the system
python server.py- π Open: http://localhost:5000
- ποΈ Edit: Click "Edit Mode" and modify content
- πΎ Save: Changes auto-backup to Backblaze B2
- π¨ Test: Click "Simulate Disaster"
- π Recover: Click "Restore" - site recovers in 60 seconds!
# Add to your .env file
ADMIN_TOKEN=your_secure_random_token_here
# Optional: Email alerts
SMTP_SERVER=smtp.gmail.com
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_app_password
ALERT_EMAIL=admin@yourdomain.comπ‘οΈ Security Features: Token auth, encrypted storage, audit logs
GET / # Website interface
GET /health # System health check
GET /metrics # Real-time metricsPOST /save-content # Save and backup content
POST /backup # Manual backup trigger
POST /restore # Disaster recovery
POST /simulate-disaster # Safe disaster testing# Include in request headers
Authorization: Bearer your_admin_token_hereGET /- Serve the websiteGET /health- Health check endpointGET /metrics- Backup metrics and statisticsPOST /save-content- Save content and trigger backup (auth required)POST /backup- Manual backup trigger (auth required)POST /restore- Restore from backup (auth required)POST /simulate-disaster- Disaster simulation (auth required)
β "Bucket not found" Error
Solution:
- Verify bucket exists in Backblaze B2 console
- Check
B2_BUCKET_NAMEin.envmatches exactly - Ensure bucket is in the correct region
π "Authentication failed" Error
Solution:
- Verify
B2_APPLICATION_KEY_IDandB2_APPLICATION_KEYin.env - Check App Key has required capabilities:
listBuckets,readFiles,writeFiles,listFiles - Generate new App Key if needed
π "No files uploaded" Warning
Solution:
- Check
SITE_DIRpath in.envis correct - Verify
docs/directory contains files - Check file permissions
- "Bucket not found": Ensure your bucket exists in Backblaze and the name matches exactly
- "Authentication failed": Double-check your
B2_APPLICATION_KEY_IDandB2_APPLICATION_KEY - "Permission denied": Ensure your App Key has the required capabilities (
listBuckets,readFiles,writeFiles,listFiles) - "No files uploaded": Check that your
SITE_DIRcontains files and the path is correct - "Authentication required": Set
ADMIN_TOKENin.envor click the Auth button
# Configuration check
python -c "from dotenv import load_dotenv; load_dotenv(); import os; print('β
B2 Bucket:', os.getenv('B2_BUCKET_NAME'))"
# Connection test
python -c "from backup_to_b2 import init_b2; print('β
B2 Connection:', init_b2())"
# Log monitoring
tail -f backup.log # Backup operations
tail -f monitor.log # Health monitoring
tail -f disaster_recovery.log # Recovery operations| Component | Technology |
|---|---|
| Backend Server | Flask (Python) |
| Cloud Storage | Backblaze B2 |
| Automation | Python scripts |
| Frontend | HTML, CSS, JS |
| Hosting | GitHub Pages |
| Logging | backup.log + metrics.json |
| Scheduling | Windows Task Scheduler / Cron |
Make sure Python 3.10+ is installed.
python -m venv venvActivate: Windows: venv\Scripts\activate
Linux/Mac: source venv/bin/activa
pip install -r requirements.txt
### 4οΈβ£ Create .env FileAdd:
B2_APPLICATION_KEY_ID=xxxx
B2_APPLICATION_KEY=xxxx
B2_BUCKET_NAME=xxxx| Variable | Description |
|---|---|
| B2_APPLICATION_KEY_ID | Backblaze key ID |
| B2_APPLICATION_KEY | Backblaze private key |
| B2_BUCKET_NAME | Your bucket name: disaster-recovery-bucket |
Start the Flask server:
python server.pyAdmin panel: http://localhost:5000/admin
Public site (when running locally): http://localhost:5000/
π Steps performed by backup_to_b2.py:
- Zip the /docs folder
- Upload to Backblaze B2
- Update metrics.json
- Append to backup.log
Backups run automatically through:
- Scheduled tasks
- Manual trigger from admin panel
The /admin dashboard has: π₯ Simulate Disaster
This will:
- Completely delete the /docs folder
- Website becomes unavailable
- Admin panel still works (because it is outside /docs)
This simulates real-world situations:
- Accidental deletion
- Corrupted deployment
- Malware / ransomware deletion
- Developer mistakes
When "Restore Website" is clicked:
- Latest backup is downloaded from Backblaze B2
- Unzipped into /docs
- Website becomes live again instantly
This demonstrates disaster recovery concepts:
- Recovery Time Objective (RTO)
- Recovery Point Objective (RPO)
backup.log shows:
text [2025-11-12] Backup successful (2.4MB) [2025-11-13] Backup failed: network error metrics.json stores:
json { "last_backup": "2025-11-14 09:33:12", "status": "SUCCESS", "backup_size": "2.4 MB" } These metrics are displayed in /admin.
Since GitHub Pages needs either:
- /docs folder
- root /
β Deployed from master branch β /docs folder
GitHub Pages website here: https://nidhi-shree.github.io/automated-cloud-backup/
GitHub Pages serves ONLY /docs site(static). Admin panel is local-only.
Admin Panel URL: http://localhost:5000/admin
Admin Panel Buttons:
| Button | Function |
|---|---|
| Backup Now | Triggers backup_to_b2.py |
| Simulate Disaster | Deletes entire /docs folder |
| Restore Website | Restores from cloud backup |
| View Logs | Shows last N log entries |
Admin panel is never deleted, even during disaster, because it lives in Flask templates folder β NOT inside /docs.
Add user authentication for admin panel
E-mail alerts on backup failure
Versioned backups with timestamps
Real-time WebSocket monitoring
Multi-cloud backup (AWS S3 + Azure Blob)
CLI tool for automation
This project demonstrates:
Real-world cloud backup automation
Disaster recovery engineering
Flask web app development
GitHub Pages deployment
Cloud storage integration
Scheduled task automation
Monitoring/logging systems



