Restore a Backup from the Command Line | BoldGrid Backup

Using BoldGrid Backup Command Line Utilities

BoldGrid’s WordPress Backup Plugin is here to make sure your site is protected from fatal errors, hacking, and data loss. Sometimes, if your website has been damaged and you cannot access the WordPress Dashboard, you may need to use the command line to get your site back up and running. The command line documentation is officially maintained on our GitHub Wiki.

Using Site Check from the Command Line

BoldGrid Backup’s Site Check is designed to be configured within the WordPress Dashboard, where it can be enabled and scheduled to run at regular intervals. However, you can run it manually.

  1. SSH into your WordPress hosting environment, using your Web Host’s instructions for doing so.
  2. Change directories into the BoldGrid Backup directory. In this example, we’re using ~/public_html as the WordPress Root directory.
    user@wordpress [~]$ cd ~/public_html/wp-content/plugins/boldgrid-backup
  3. Run the check by using the command php cli/bgbkup-cli.php
    user@wordpress [wp-content/boldgrid-backup]$ php cli/bgbkup-cli.php
    Info: No action taken.
  4. Examine the output from your command. If no action was taken, your Site Check passed.
  5. Optionally, you can configure the error log level with the command php cli/bgbkup-cli.php check log which will log any errors with the severity LOG_NOTICE or higher.
  6. Optionally, you can auto-recover from a failure, which will restore the most recent backup, using the command php cli/bgbkup-cli.php check auto_recovery=1

Restoring a Backup from the Command Line

  1. SSH into your WordPress hosting environment, using your Web Host’s instructions for doing so.
  2. Change directories into the BoldGrid Backup directory. In this example, we’re using ~/public_html as the WordPress Root directory.
    user@wordpress [~]$ cd ~/public_html/wp-content/plugins/boldgrid-backup
  3. Restore the most recent backup using the command php cli/bgbkup-cli.php restore
    user@wordpress [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.
  4. Optionally, if you need to restore a different backup from the command line, you can specify the filename:
    user@wordpress [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.

Congratulations! You now know how to keep your site safe and restore a backup from the command line in an emergency.

 

SIGNUP FOR

BOLDGRID CENTRAL  

   200+ Design Templates + 1 Kick-ass SuperTheme
   6 WordPress Plugins + 2 Essential Services

Everything you need to build and manage WordPress websites in one Central place.