WP-CLI is the command line of WordPress. With it you control cloneworx Backup without a browser, for example for backups that the server itself triggers. This is how you install WP-CLI and check whether the commands of the plugin are there.
The steps follow the guide by hostnet: Wie installiere ich WP-CLI? User, group and paths may have different names at your hosting provider.
What you need
- SSH access to the server,
- PHP for the command line,
- curl,
- sudo rights if you install WP-CLI for the whole server. It also works without sudo rights: see the section “Without sudo rights”.
Log in to the server via SSH and change to a folder in which you may write, for example to your home directory.
Never run WP-CLI as root
WordPress, plugins and themes would also get the rights of root. Run WP-CLI as the user who owns the website.
Step 1: Download WP-CLI
curl -fLO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Afterwards the file wp-cli.phar is in the folder you are currently in.
Step 2: Check the file
php wp-cli.phar --info
The output names the versions of PHP and WP-CLI. This step is optional.
Step 3: Make the file executable
chmod 755 wp-cli.phar
With these permissions the user of the website can run the file too.
Step 4: Install WP-CLI for the whole server
sudo mv wp-cli.phar /usr/local/bin/wp
The command moves the file to /usr/local/bin and names it wp. From now on you call WP-CLI with wp.
Step 5: Test as the user of the website
sudo -u web -g vuser -H wp --info
At hostnet the web server runs as the user web in the group vuser. If user and group have different names at your provider, for example because your website runs with suEXEC, you put the user and the group of your website here. If the command shows the details on system, PHP and WP-CLI without an error message, WP-CLI is installed.
Without sudo rights
If you have no sudo rights, the file stays in your folder, and you call it with PHP. Steps 3 to 5 are not needed.
# Instead of wp: php and the path to the file php ~/wp-cli.phar --info
The example applies to a file that is in your home directory. Wherever this help says wp, you then write php and the path to the file, here php ~/wp-cli.phar.
Finally: Are the commands of the plugin there?
Change to the folder of your website, that is, the folder in which WordPress is located. There, query the state of the website:
# In the website's folder cd /pfad/zur/website wp cloneworx-backup status # With sudo as the website's user sudo -u web -g vuser -H wp cloneworx-backup status # Without sudo rights, with the file in your own folder php ~/wp-cli.phar cloneworx-backup status
The output is in English. The first line names the state of the website, for example State: none (no backup yet): there is no backup yet. Below it follow, among other things, the last backup as soon as there is one, and the number of plans and targets. It is the same result that the status tile of the Overview page shows.
If the command answers like this, the commands of the plugin are there. Which ones exist is shown in The commands at a glance.
When something does not work
| What happens | What you can do |
|---|---|
You may not use sudo. |
Take the way from the section “Without sudo rights”. |
WP-CLI does not know the command cloneworx-backup. |
The plugin registers its commands only if it is active on this website. Check whether you are in the folder of the right website and whether cloneworx Backup is activated there. On a WordPress multisite installation the commands do not exist: cloneworx Backup does not support multisite. |
A command of the plugin aborts. Its message says This command runs as user, and it names two users. |
You are working as a different user than the one who owns the folders of the plugin. Run the command as the user of the website, as in step 5. |
Good to know
- The outputs of all commands of the plugin are in English and are not translated.
- Almost every command that changes something or starts a job first checks whether you are working as the user who owns the folders of the plugin. The website could not change or delete files and folders of another user later on.
- The command line never accepts passwords and keys. You set up targets with credentials on the Targets page.