Backup WordPress files and database via SSH

This one-liner will backup your WordPress files and database into a directory name with today’s date.

mkdir -p ../backup/$(date +%Y-%m-%d) ; mysqldump $(grep DB_NAME wp-config.php | grep -v WP_CACHE_KEY_SALT | cut -d \' -f 4) | gzip > ../backup/$(date +%Y-%m-%d)/db.sql.gz ; rsync -ahv --exclude 'wp-content/backups' --exclude 'wp-content/cache' . ../backup/$(date +%Y-%m-%d)/

Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.