-
Notifications
You must be signed in to change notification settings - Fork 9
CLI Commands
Total Upkeep includes several tools available to you from the command line. These include:
Run the help command to display help/usage.
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php help
Usage: php bgbkup-cli.php <check|restore> [log] [notify] [email=<email_address>] [method=<ajax|cli|pclzip|ziparchive>] [zip=<path/to/backup.zip>] [log_level=<(LOG_EMERG|LOG_ALERT|LOG_CRIT|LOG_ERR|LOG_WARNING|LOG_NOTICE|LOG_INFO|LOG_DEBUG)|(0-7)>]
@since 1.10.0
Description
Site Check is a feature that detects errors when WordPress runs. It can log the errors and it can email you a status report as well.
Site Check vs. Site Health
Total Upkeep's Site Check was actually developed during the same time that WordPress Core was developing their own Site Health feature. Total Upkeep's Site Check has a few advantages over the similar WordPress Core feature.
- It runs "outside" of WordPress. WordPress' Site Health cannot catch all fatal errors, however, Total Upkeep's Site Check can.
- It can keep a running log of errors, so you have a historical record.
- It gives Site Health functionality for those who have not yet upgraded to WordPress 5.2
- It includes recovery options. While WordPress' Site Health alerts you of errors, Total Upkeep's Site Check functionality can auto restore your website.
Usage
Site Check was designed to be configured within the Total Upkeep Settings page and then ran on an interval using cron. However, you can run Site Check manually from the command line.
Site Check includes several options:
Performs a Site Check and reports status.
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php check
Info: No action taken.
More Help
What to do when Total Upkeep Site Check fails 🔗
Using Total Upkeep Command Line Utilities 🔗
Checking Your WordPress Core Files with WP-CLI 🔗
@since 1.10.0
A flag log can be passed to enable logging (to a file "bgbkup-cli.log" in the same directory as the utility). The default log level is "LOG_NOTICE".
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php check log
@since 1.10.0
Defines the level of logging in the utility, written to the "bgbkup-cli.log" log file. It does not specify what level of errors/warnings raise when checking the site.
The log level default is "LOG_NOTICE", and can be set per-use by including a log_level argument in the command.
This argument uses log level constants in PHP core:
| Level | Integer | Description |
|---|---|---|
| LOG_EMERG | 0 | System is unusable. |
| LOG_ALERT | 1 | Action must be taken immediately. |
| LOG_CRIT | 2 | Critical conditions. |
| LOG_ERR | 3 | Error conditions. |
| LOG_WARNING | 4 | Warning conditions. |
| LOG_NOTICE | 5 | Normal, but significant, condition. |
| LOG_INFO | 6 | Informational message. |
| LOG_DEBUG | 7 | Debug-level message. |
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php check log log_level=LOG_DEBUG
Info: No action taken.
[user@host wp-content/boldgrid-backup]$ cat cli/bgbkup-cli.log
2019-05-02 09:49:05 [INFO] Operational mode set to "check".
2019-05-02 09:49:05 [INFO] Chosen restoration method: "ziparchive".
2019-05-02 09:49:05 [DEBUG] Gathered information.
2019-05-02 09:49:06 [INFO] Info: No action taken.
@since 1.10.0
An argument flag notify can be passed to enable email notification when there is a failed Site Check. An email message is sent to the specified email address via command argument.
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php check log notify [email protected]
@since 1.10.0
A command argument auto_recovery can be passed set to either 0 or 1, which will trigger an automatic restoration from the last full backup archive if a Site Check has failed.
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php check auto_recovery=1
@since 1.9.0
As of Total Upkeep 1.9.0, a restoration script is included so that backups can be restored outside of WordPress. For example, if WordPress has crashed, the standard restoration script will not work as it relies on WordPress. The new restoration script allows backups to be restored in the event WordPress itself has been corrupted.
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php restore
Starting restoration process...
Attempting to restore "https://domain.com" from backup archive file "/home/user/boldgrid_backup/backup.zip"...
Cannot reach the site URL; using standalone restoration process...
Attempting file restoration using PHP ZipArchive...
Success.
Attempting to restore database using PHP PDO...
Success.
Force a site restoration using a specific ZIP file.
[user@host wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php restore zip=/home/user/boldgrid_backup/backup.zip
Starting restoration process...
Attempting to restore "https://domain.com" from backup archive file "/home/user/boldgrid_backup/backup.zip"...
Cannot reach the site URL; using standalone restoration process...
Attempting file restoration using PHP ZipArchive...
Success.
Attempting to restore database using PHP PDO...
Success.