What to Backup
microfeed stores data in two locations:- D1 Database - SQLite database containing all metadata (channels, items, settings)
- R2 Storage - Media files (audio, video, images, documents)
Backing Up D1 Database
The D1 database contains all your content metadata. You’ll use Wrangler CLI to export it.Prerequisites
Install Wrangler if you haven’t already:List Your Databases
First, find your database name:FEED_DB.
Export Database
Export the entire database to a SQL file:microfeed-backup-20260301.sql containing:
- Complete database schema
- All table data as SQL INSERT statements
- Timestamps and metadata
Export Specific Table
To export only one table:Verify Backup
Check that your backup file was created:- Small blog: ~100KB - 1MB
- Medium podcast: 1MB - 10MB
- Large site: 10MB+
Automated Backups
Create a backup script that runs daily:Backing Up R2 Media Files
R2 stores all media files uploaded to your microfeed. You’ll use S3-compatible tools to download them.Why R2 Backup is Important
As of February 2023, Cloudflare does not provide a built-in UI to browse or bulk download R2 files. You need to use S3-compatible APIs.Using AWS CLI
The AWS CLI works with R2’s S3-compatible API.Install AWS CLI
Configure AWS CLI for R2
Create an AWS profile for R2:Download All Files
Sync your entire R2 bucket to a local directory:your-bucket-namewith your R2 bucket name (from.vars.tomlor GitHub secrets)[account-id]with your Cloudflare account ID
List Files
To see what’s in your bucket:Using rclone
rclone is another powerful tool for syncing cloud storage.Install rclone
Configure rclone for R2
Sync R2 to Local
Automated R2 Backup Script
Scripted Backup Example
Here’s a Python script to backup R2 files:Restoring from Backup
Restore D1 Database
To restore a D1 database from a backup:Restore Specific Records
If you only need to restore specific items, edit the SQL file to keep only the relevant INSERT statements, then run:Restore R2 Files
To restore media files back to R2:Backup Best Practices
Frequency
- Daily backups for active sites
- Weekly backups for infrequently updated sites
- Before major changes (always backup before updates)
Storage Locations
Store backups in multiple locations:- Local machine - Fast access, but vulnerable to hardware failure
- External drive - Offline backup protection
- Cloud storage - AWS S3, Google Cloud Storage, Dropbox, etc.
- Version control - Git for database schema (not full data)
Retention Policy
Keep backups for:- Daily backups: 7 days
- Weekly backups: 4 weeks
- Monthly backups: 12 months
- Yearly backups: Indefinitely
Testing Restores
Regularly test your backups:- Restore to a test environment
- Verify data integrity
- Check that media files load correctly
- Confirm feed generation works
Migration to Another Platform
If you need to migrate away from Cloudflare:- Export D1 database - You’ll have a standard SQLite database
- Download R2 files - S3-compatible tools work with any platform
- Convert data - Write scripts to transform data for your new platform
- Import to new system - Most CMSs support SQL imports
Support
If you encounter issues with backups:- Check Cloudflare D1 documentation
- Check Cloudflare R2 documentation
- Review Wrangler commands
- Email [email protected]