Automate daily WordPress backups to Amazon S3 for reliable off-site disaster recovery.
Category: WordPress
Option 1 — UpdraftPlus (Plugin)
The easiest approach: install UpdraftPlus from the plugin directory.
- Go to Settings → UpdraftPlus Backups
- Set schedule (daily/weekly) and retention (e.g. keep 7 copies)
- Under Remote Storage, select Amazon S3
- Enter your AWS Access Key, Secret Key, and bucket name
- Run a manual backup to test
Option 2 — Script + AWS CLI
#!/bin/bash
# /opt/wp-backup.sh
DATE=$(date +%Y-%m-%d)
WP_DIR="/var/www/html"
DB_NAME="wordpress"
S3_BUCKET="s3://your-backup-bucket/wordpress"
# Dump the database
mysqldump -u root "$DB_NAME" | gzip > "/tmp/wp-db-${DATE}.sql.gz"
# Archive wp-content
tar -czf "/tmp/wp-content-${DATE}.tar.gz" "${WP_DIR}/wp-content"
# Upload to S3
aws s3 cp "/tmp/wp-db-${DATE}.sql.gz" "${S3_BUCKET}/"
aws s3 cp "/tmp/wp-content-${DATE}.tar.gz" "${S3_BUCKET}/"
# Clean up
rm -f "/tmp/wp-db-${DATE}.sql.gz" "/tmp/wp-content-${DATE}.tar.gz"
echo "WordPress backup complete: $DATE"
chmod +x /opt/wp-backup.sh
# Schedule daily at 2 AM
crontab -e
# 0 2 * * * /opt/wp-backup.sh >> /var/log/wp-backup.log 2>&1
Restore from S3
# Download backup
aws s3 cp s3://your-backup-bucket/wordpress/wp-db-2026-05-01.sql.gz /tmp/
aws s3 cp s3://your-backup-bucket/wordpress/wp-content-2026-05-01.tar.gz /tmp/
# Restore DB
gunzip -c /tmp/wp-db-2026-05-01.sql.gz | mysql -u root wordpress
# Restore wp-content
tar -xzf /tmp/wp-content-2026-05-01.tar.gz -C /var/www/html/