I threw together a simple bash script to be run via cron jobs that will backup an entire WordPress site. Technically, it will work for a lot more than that assuming the site you’re backing up has a single directory to be backed up and a MySQL/MariaDB database. It’s a fairly simple script and it is easy to expand to work with multiple directories. Just take a look at the source for yourself!
To use, fill in the information at the top of the script (site name, database name, database user + password, path to site, and backup path), upload the script to
/etc/cron.daily/ on your server and you’ll be good to go!
Take note of the
SITE_PATH variable at the top of the script. For whatever reason, there needs to be a space between the first “/” and the rest of the path.