This project provides an automated backup solution for Cloudflare D1 databases. It creates SQL backups of your D1 database and stores them locally with timestamped filenames.
- Automated backups of Cloudflare D1 databases
- Timestamped backup files for easy version tracking
- Environment variable configuration for secure credential management
- Error handling and logging
-
Clone this repository:
git clone https://github.com/yourusername/cloudflare-d1-backup.git cd cloudflare-d1-backup
-
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env
Then, edit the
.env
file and fill in your Cloudflare credentials.
Edit the .env
file and provide the following information:
CLOUDFLARE_ACCOUNT_ID
: Your Cloudflare account IDCLOUDFLARE_DATABASE_ID
: Your D1 database IDCLOUDFLARE_API_KEY
: Your Cloudflare API key
To create a backup, run:
node index.js
This will create a backup file in the backups
directory with a timestamp in the filename.
This project is licensed under the MIT License - see the LICENSE file for details.