Create Offsite WordPress Database Backup with WP-CLI and CURL/FTP

WP-CLI is a crazy powerful tool for automating WordPress tasks, but did you know you can add a bit of curl to it to automate offsite backups?

In a quick script, which requires a bit of editing to be usable, shows how you can export the filename to a bash variable and use that variable to upload the file to a remote FTP server.

To make this script usable, either load it from your wordpress directly, or uncomment and adjust the cd command, and then replace HOSTNAME with your FTP hostname and replace USERNAME and PASSWORD with your credentials.

If you’re FTP server doesn’t support FTP-SSL, remove –ftp-ssl, but I would strongly advise keeping this on, as this is your WordPress database and may contain sensitive information.