This Docker setup provides a WordPress installation with automated backup and restoration capabilities. It uses Cloudflare R2 for storing backups and includes scripts for easy backup and restoration of both files and database.
- Automated WordPress installation
- Automatic backup of files and database
- Automatic restoration from latest backup for new installations
- Cloudflare R2 integration for backup storage
- Cron jobs for scheduled backups
The following environment variables are required:
WORDPRESS_URL
: The URL of your WordPress site (e.g.,https://example.com
)WORDPRESS_TITLE
: The title of your WordPress siteWORDPRESS_ADMIN_USER
: Admin usernameWORDPRESS_ADMIN_PASSWORD
: Admin passwordWORDPRESS_ADMIN_EMAIL
: Admin email addressWORDPRESS_DB_HOST
: Database hostWORDPRESS_DB_NAME
: Database nameWORDPRESS_DB_USER
: Database userWORDPRESS_DB_PASSWORD
: Database password
R2_BUCKET
: Your Cloudflare R2 bucket nameR2_ACCESS_KEY_ID
: R2 access key IDR2_SECRET_ACCESS_KEY
: R2 secret access keyR2_ENDPOINT
: R2 endpoint URL
- Clone this repository
- Set the required environment variables
- Build and run the Docker container
Backups are automatically created according to the cron schedule. To manually trigger a backup or restore:
- Backup files:
docker exec -it container_name /usr/local/bin/file-backup.sh
- Backup database:
docker exec -it container_name /usr/local/bin/db-backup.sh
- Restore files:
docker exec -it container_name /usr/local/bin/restore-files.sh
- Restore database:
docker exec -it container_name /usr/local/bin/restore-db.sh
For silent operation (auto-selecting the latest backup), add the --silent
flag to the restore commands.
You can modify the cron schedule by editing the cron.job
file in the Docker context directory.
Ensure that your environment variables, especially passwords and API keys, are kept secure and not exposed in public repositories.