WP-CLI bash scripts to maintain WordPress installations.
These scripts work best on servers where your WordPress websites are all stored in the same "webroot" directory. If these scripts are installed correctly, they will calculate any required pathnames correctly.
A typical webroot directory looks like this:
/home/user/public_html
/srv/www/
Inside of the webroot directory, your server will host one or more website directories.
These scripts work with WordPress installations
- A web server with bash configured correctly
- A user account to run these scripts with read and write access to the webroot directory (ideally not "root")
- Unzip or clone (using git) the
wpclish
directory (this repository) into your webroot directory. Do not place the directory inside a website subdirectory, as this poses a major security risk! - Run the scripts at the command line via SSH to test them on your system.
- Once you've demonstrated that the scripts work you can also set up a cron job for each script.
A brief description of each script.
This script backs up all of the sites found in the webroot directory. The script assumes you've placed this code repository in the webroot directory with the website directories. It will also create a sqlbackup
directory to store the compressed backup files in the webroot directory.
The script will:
- Check each directory inside the webroot directory.
- Ignore any directories on the ignore list.
- For the remaining directories, attempt to check the WordPress database.
- If the check is successful, the script will backup and compress the WordPress database to the
sqlbackup
directory. - Then, the script will optimize the WordPress database and back up the optimized version.
This script convert all colors in the database from one palette to another using search and replace. You can use this with any number of hex values; the example script uses five. Both lists, currentcolors
and newcolors
must contain the same number of colors and the color value substitutions are made based on the position of the color in the list.