Here’s a new version of the wp-cli backup script mentioned previously. This adds a check that it’s running as a user, and backs up the upload directory too.
You need to have wp-cli installed and run this in your WordPress root, as a regular (non-root) user.
If you use this I’d love to hear from you in the comments.
Hi,
Thank you for sharing the script…
Just a few things,
1. Why do you check if the backups directory is writable twice (WPBKUPS and WPBKUPSROOT) what is the difference between the 2?
2.When I run the script I get the following error
—
+ ‘[[‘ -eq 0 ]]
./wpcli_db_backup.sh: [[: not found
+ WPBKUPS=/usr/local/www/production/wpbackup
+ [ -d /usr/local/www/production/wpbackup ]
+ [ -w /usr/local/www/production/wpbackup ]
+ echo ‘Backups directory /usr/local/www/production/wpbackup is writable; proceeding.\n’
Backups directory /usr/local/www/production/wpbackup is writable; proceeding.\n
+ BKUPLOG=/usr/local/www/production/wpbackup/quickbackupwp.log
+ exec
$WPBKUPS is /usr/local/www/production/wpbackup\n
—
Could you please assist?
Thank you
Hey Fred,
The different backup directories it looks for are first a local ./backups or then falling back to a system wide (root) /backup location. When on a multi-site server I made the root version so I could backup all sites to there, you could do it to a home directory or something like that if you prefer.
That error looks like it’s not being run with bash (e.g. with sh etc) due to the “[[” bash built-in not getting recognised. Try running it with the command “bash ./wpcli_db_backup.sh”.
HTH.
Alastair.