WorryFree Computers   »   [go: up one dir, main page]

Skip to content

Manually Restore Your Site from a Jetpack Backup File on WordPress.com

It is often possible to restore your site with a click of a button using Jetpack VaultPress Backup, but there may come a time when you need to manually restore a version of your site using a backup file you have previously downloaded. 

If you manage a WordPress.com site whose Creator or Entrepreneur plan recently expired, first try following these steps, as your site’s backups may still be available for one-click restoration.

If you’re transferring files to a new domain (i.e. if the files you’re importing used to live on a different domain than the one you’re now using), be sure to follow the instructions for updating your domain in your database below. If you’re restoring your files to a site with the same domain, you may skip that step.

Transfer Plugins, Themes, Uploads, and Database Files

You can manually restore your WordPress.com site using a Jetpack .tar.gz backup file by following the video (~3 minutes) or steps below:

  1. You must have an active WordPress.com Creator or Entrepreneur plan in order to follow these instructions. If you don’t already have one, sign up for a seven-day free trial here, or start on a paid plan.
  2. Enable SFTP credentials for your WordPress.com Creator or Entrepreneur plan by following these instructions. You’ll also need to connect to SFTP using an SFTP client. We’ll use FileZilla during this tutorial.
  3. Unzip your .tar.gz file. On Mac, you can double-click the file. On Windows, you can use an archiving tool (like 7-Zip). The unzipped folder will contain your site data in the following sub-folders: wp-content (which contains your plugins, themes, and uploads folders) and .sql.
  4. Once FileZilla is connected to your site, go to the /srv/htdocs folder. Within that folder, open wp-content.
  5. Open the plugins folder, and you’ll see a list of plugins currently installed on your site.
    • About symlinked files and folders: On a WordPress.com website, we symbolically link (symlink) WordPress Core files as well as WordPress.com’s own themes and plugins. By using symlinks, we can ensure that the files on your website are always up-to-date and secure.
      • To identify a symlinked folder or file, some FTP clients may show a tiny arrow on the bottom-left part of the folder icon. On others, it might have a question mark over it.
      • You won’t be able to access or edit the symlinked files, as they are managed on the platform level.
      • Learn more about symlinked folders and files here.
  6. Check the plugins folder from your backup and compare it to the plugins folder you have in FileZilla. Any plugin can be restored by dragging the entire plugin folder from your backup to FileZilla, provided the plugin is not symlinked. Skip any symlinked plugins, and transfer any others you wish to restore on your site.
  7. Repeat this process with your themes and uploads folders.
  8. Next, you’ll need to restore your database files. Drag the sql folder from your backup into the htdocs folder on FileZilla. 
  9. Open the Terminal on your computer and connect to your site via SSH.
  10. Once connected, type cd htdocs/sql, then press return/enter on your keyboard.
  11. Type ls | xargs -I % wp db import %, then press return/enter on your keyboard.
    • This lists every file in the folder, wraps the files, and then runs wp db import all with one command.
  12. Run wp cache flush, then press return/enter on your keyboard.
    • You must flush the cache every time you make changes to your database.

Any plugin or theme settings you had enabled at the time of your backup should now be enabled on your site. 

Update Your Domain in the Database

When restoring your site to a different domain, you’ll need to update all mentions of your old domain in the database. If you’re restoring your site files to a site with the same domain, you should skip this section. 

You can edit your newly-imported database using phpMyAdmin or WP-CLI.

Update siteurl and home Values with phpMyAdmin

To update your siteurl and home database values in the wp_options table using phpMyAdmin:

  1. Visit your site’s dashboard.
  2. Click the Overview button.
  3. Click the Server Settings tab.
  4. Click the Open phpMyAdmin button.
  5. To view your siteurl and home values, click the SQL button in the top toolbar, and run the following queries:
/* Run these queries to get your current site URL */
SELECT * FROM `wp_options` WHERE `option_name` = 'siteurl';

SELECT * FROM `wp_options` WHERE `option_name` = 'home';
  1. To update your siteurl and home values, click the SQL button in the top toolbar and run the following queries, replacing NEW-DOMAIN with your new domain:
/* Run these queries to update your site URL to your new domain */
UPDATE wp_options SET option_value = 'NEW-DOMAIN' WHERE wp_options.option_name = 'siteurl';

UPDATE wp_options SET option_value = 'NEW-DOMAIN' WHERE wp_options.option_name = 'home';

Search and Replace with phpMyAdmin

To ensure that images load as expected, you should also run search-replace queries to update any references to your old URL:

  1. Visit your site’s dashboard.
  2. Click the Overview button.
  3. Click the Server Settings tab.
  4. Click the Open phpMyAdmin button.
  5. Click the SQL button in the top toolbar, and run the following queries, replacing OLD-DOMAIN with your old domain name and NEW-DOMAIN with your new domain name:
/* Run these queries to update the old domain to your new domain */
UPDATE wp_posts SET post_content = replace(post_content, 'OLD-DOMAIN', 'NEW-DOMAIN');

UPDATE wp_posts SET guid = replace(guid, 'OLD-DOMAIN','NEW-DOMAIN');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'OLD-DOMAIN','NEW-DOMAIN');

UPDATE wp_links SET link_image = replace(link_image, 'OLD-DOMAIN','NEW-DOMAIN');

Update siteurl and home Values with WP-CLI

To update your siteurl and home database values in the wp_options table using WP-CLI:

  1. Open the Terminal on your computer and connect to your site via SSH.
  2. Once connected, type cd htdocs/sql, then press return/enter on your keyboard.
  3. To view your siteurl and home values, run the following commands one at a time:
    • wp option get siteurl
    • wp option get home
  4. To update your siteurl and home values, run the following commands one at a time, replacing NEW-DOMAIN with your new domain:
    • wp option update siteurl NEW-DOMAIN
    • wp option update home NEW-DOMAIN
  5. Run wp cache flush, then press return/enter on your keyboard.

Search and Replace with WP-CLI

To ensure that images load as expected, you should also run a search-replace command to update any references to your old URL:

  1. Open the Terminal on your computer and connect to your site via SSH.
  2. Run the following command, replacing OLD-DOMAIN with your old domain name and NEW-DOMAIN with your new domain name:
    • wp search-replace OLD-DOMAIN NEW-DOMAIN --skip-columns=guid
  3. Run wp cache flush, then press return/enter on your keyboard.

Frequently Asked Questions

What if something goes wrong?

If something unwanted happens to your site as a result of actions in SFTP, in phpMyAdmin, or with WP-CLI, you can restore a recent backup of your site. If you’re still having trouble, connect with our Happiness Engineers here.

Last updated: June 07, 2024