Backup script generator
Database + wp-content, ready for cron.
Genuinely free. No sign-up, no email, no limits, no cookies. We don't store the URL you analyse.
Code
#!/usr/bin/env bash
set -euo pipefail
BACKUP_DIR='/home/user/backups'
WP_ROOT="$(pwd)"
TIMESTAMP="$(date +%Y-%m-%d_%H-%M-%S)"
mkdir -p "$BACKUP_DIR"
# Database dump
wp db export "$BACKUP_DIR/db-$TIMESTAMP.sql" --path="$WP_ROOT"
# wp-content archive (themes, plugins, uploads)
tar czf "$BACKUP_DIR/wp-content-$TIMESTAMP.tar.gz" -C "$WP_ROOT" wp-content
# Remove backups older than 7 day(s)
find "$BACKUP_DIR" -type f \( -name '*.sql' -o -name '*.tar.gz' \) -mtime +7 -delete
echo "Backup done: $BACKUP_DIR/db-$TIMESTAMP.sql and wp-content-$TIMESTAMP.tar.gz"
# Add to crontab with: crontab -e
# 0 3 * * * /path/to/this-script.sh >> /var/log/wp-backup.log 2>&1What it's for
Many hosts with SSH access offer WP-CLI but no automatic backup included. This script exports the database and archives wp-content (themes, plugins, uploads), cleaning up backups older than the chosen threshold on its own. Meant to be run from cron.
Frequently asked questions
›Does it also upload the backup to external storage (S3, Dropbox)?
No, it stays a simple local script: it only saves to the server's filesystem. Adding a cloud upload requires credentials and a specific service, which is outside the scope of this generator.