{"id":159239,"date":"2016-09-23T13:00:51","date_gmt":"2016-09-23T13:00:51","guid":{"rendered":"https:\/\/premium.wpmudev.org\/blog\/?p=159239"},"modified":"2016-09-22T06:16:31","modified_gmt":"2016-09-22T06:16:31","slug":"testing-wordpress-backups","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/testing-wordpress-backups\/","title":{"rendered":"Testing WordPress Website Backups to Avoid Future Disasters"},"content":{"rendered":"<p>If you&#8217;ve used WordPress for a while, you know keeping regular backups can save you from losing your website (you know, the site you&#8217;ve put all that time and effort \u2013 literally hours \u2013 into building). But have you tested your WordPress backups to see if they actually work?<\/p>\n<p>Sometimes, backups could be missing files or become corrupted. It may not be a common occurrence, but can you afford to take that risk the next time you need to restore your site?<\/p>\n<p>Your WordPress backup could become unusable for many possible reasons, some of which include:<\/p>\n<ul>\n<li>Your backup software experiences an issue\n<ul>\n<li>It contains bugs<\/li>\n<li>There&#8217;s a compatibility issue with other plugins or WordPress core<\/li>\n<\/ul>\n<\/li>\n<li>There&#8217;s a temporary glitch\n<ul>\n<li>Your internet connection becomes severed unexpectedly<\/li>\n<li>You <a href=\"https:\/\/wpmudev.com\/blog\/increase-memory-limit\/\" target=\"_blank\" rel=\"noopener\">reach your server&#8217;s PHP memory limit<\/a> as a backup is being made<\/li>\n<\/ul>\n<\/li>\n<li>Your computer has been infected by a virus<\/li>\n<li>A hacker infiltrates your site and a backup is created with malware or other unwanted content<\/li>\n<\/ul>\n<p>Instead of guessing and hoping everything&#8217;s fine, in this post I&#8217;ll show you the ropes of testing a backup locally or with our <a href=\"https:\/\/wpmudev.com\/project\/snapshot\/\" target=\"_blank\" rel=\"noopener\">Snapshot Pro plugin<\/a> to ensure you have at least one backup you can rely on.<\/p>\n<p><strong><em>Note: If you run into troubles along the way, you don&#8217;t have to go it alone. <a href=\"https:\/\/wpmudev.com\/support\/\" target=\"_blank\" rel=\"noopener\">Ask our expert support heroes<\/a> and they&#8217;ll help you out in the flashes of flashes. If you&#8217;re not a WPMU DEV member yet, you can still <a href=\"https:\/\/wpmudev.com\/\" target=\"_blank\" rel=\"noopener\">sign up for a premium account for free<\/a> and get help from our heroes in your hour of need.<\/em><\/strong><\/p>\n<h2>Testing Your WordPress Backups Locally<\/h2>\n<p>Before you can test your backup locally, you need to install and fire up the local environment of your choice. In case you don&#8217;t have a program installed already to do this, here are some other posts with details on setting up many different options:<\/p>\n<ul>\n<li><a href=\"https:\/\/wpmudev.com\/blog\/setting-up-xampp\/\" target=\"_blank\" rel=\"noopener\">How to Install XAMPP and WordPress Locally on PC\/Windows<\/a><\/li>\n<li><a href=\"https:\/\/wpmudev.com\/blog\/develop-wordpress-locally-mamp\/\" target=\"_blank\" rel=\"noopener\">How to Develop WordPress Locally with MAMP<\/a><\/li>\n<li><a href=\"https:\/\/wpmudev.com\/blog\/how-to-set-up-wordpress-locally-for-pcwindows-with-wamp\/\" target=\"_blank\" rel=\"noopener\">How to Set Up WordPress Locally for PC\/Windows with WampServer<\/a><\/li>\n<li><a href=\"https:\/\/wpmudev.com\/blog\/move-wordpress-xampp\/\" target=\"_blank\" rel=\"noopener\">How to Move WordPress for Local Development with XAMPP<\/a><\/li>\n<\/ul>\n<p>Once you have one of these or a similar program installed on your computer, uncompress your backup and locate your <em>wp-config.php<\/em> file.<\/p>\n<p>In most cases, you should be able to find the following in your uncompressed WordPress backup:<\/p>\n<ul>\n<li>A backup of your database, usually as an SQL, ZIP or GZIP file<\/li>\n<li>Your WordPress core and custom files<\/li>\n<\/ul>\n<p>Some WordPress backups won&#8217;t include these files in quite the same structure, which means you may need to <a href=\"https:\/\/wpmudev.com\/blog\/creating-manual-backup\/\" target=\"_blank\" rel=\"noopener\">create a manual backup<\/a> or on your local environment, you would need to install the same plugin or program you use for backups. From there, you would restore your WordPress backup to test it out.<\/p>\n<p>You should also consult the documentation for your backup software if you&#8217;re not sure how to complete these steps since it would be different from other programs and plugins.<\/p>\n<p>Speaking of documentation, if you prefer to know how to restore a Snapshot, skip down to that section below. You can also view <a href=\"https:\/\/wpmudev.com\/project\/snapshot\/#product-usage\" target=\"_blank\" rel=\"noopener\">Snapshot Pro&#8217;s documentation<\/a> and check out <a href=\"https:\/\/wpmudev.com\/blog\/backup-with-snapshot\/\" target=\"_blank\" rel=\"noopener\">How to Backup Your WordPress Website (and Multisite) Using Snapshot<\/a>.<\/p>\n<h3>Finding Your Database Credentials<\/h3>\n<p>Assuming you have uncompressed your WordPress backup and found your database file and your WordPress files, open up your <em>wp-config.php<\/em> file and look for the following similar lines:<\/p>\n<div class=\"gist\" data-gist=\"152687d2c98c20ec43fc1392faf23560\" data-gist-file=\"wp-config.php\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/152687d2c98c20ec43fc1392faf23560.js?file=wp-config.php\">Loading gist 152687d2c98c20ec43fc1392faf23560<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>Make a note of your database&#8217;s name. You can find it listed after <code>DB_NAME<\/code>\u00a0and instead of seeing\u00a0<code>database_name_here<\/code>, your real database&#8217;s name would be written there.<\/p>\n<p>Similarly, make a note of your database&#8217;s username which you would see instead of <code>username_here<\/code>. Also, record the password which would replace <code>password_here<\/code> in the above example.<\/p>\n<p>Head back to your local environment program and open up phpMyAdmin. The location is different for each software so consult their documentation if you&#8217;re not sure where to find it.<\/p>\n<h3>Creating a New Database<\/h3>\n<p>In phpMyAdmin, create a new\u00a0database by clicking the New button in the menu on the left.<\/p>\n<div  class=\"wpdui-pic-regular  \">\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/09\/phpMyAdmin-local-new.png\" alt=\"phpMyAdmin main page\" width=\"670\" height=\"300\" \/><figcaption class=\"wp-caption-text\">Start by creating a new database.<\/figcaption><\/figure>\n<\/div>\n<p>Under the <strong>Create database<\/strong> field, enter the name of the database for your original site which you made note of earlier, then click <strong>Create<\/strong>.<\/p>\n<p>The default for the <strong>Collation<\/strong> drop down box should be fine in most cases, but if you find that you run into issues later on, backtrack and try these steps again, but choose <code>uft8_bin<\/code> instead.<\/p>\n<div  class=\"wpdui-pic-large   \" >\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/09\/phpMyAdmin-create-database.png\" alt=\"Databases page in phpMyAdmin\" width=\"1364\" height=\"400\" \/><figcaption class=\"wp-caption-text\">You need to create a new, empty database before you can import your existing one.<\/figcaption><\/figure>\n<\/div>\n<h3>Creating a New Database User<\/h3>\n<p>Now that you have created a new database for your backup-testing site, you need to create a user for it.<\/p>\n<p>If you don&#8217;t create a user for your database that&#8217;s the same as the one you noted earlier in your <em>wp-config.php<\/em> file, your test site for your backup won&#8217;t work. Although, you can assign one of the existing users to your database and update your <em>wp-config.php<\/em> file later.<\/p>\n<p>If you think this would be easier for you, go ahead and click <strong>Edit Privileges<\/strong> for the existing user of your choice. On the next page, select all privileges, then under <strong>Privileges &gt; Database<\/strong>, select the new database you created, then click <strong>Go<\/strong>.<\/p>\n<p>If you prefer not to edit your core files, you can add a new user instead.\u00a0Once your database has been successfully created, click on the <strong>Privileges<\/strong> tab while your new database is highlighted on the left, then click on the <strong>Add user<\/strong> link.<\/p>\n<div  class=\"wpdui-pic-large   \" >\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/09\/phpMyAdmin-privileges-new-user.png\" alt=\"The database privileges page\" width=\"1364\" height=\"400\" \/><figcaption class=\"wp-caption-text\">After creating a new database, create a user for it by clicking on the <strong>Privileges<\/strong> tab.<\/figcaption><\/figure>\n<\/div>\n<p>On the next page, enter the username and password you made note of earlier that was written in your <em>wp-config.php<\/em> file. Under <strong>Database for user<\/strong>, be sure that the third checkbox is the only one checked for <strong>Grant all privileges on database<\/strong>. It should be checked by default.<\/p>\n<p>If you don&#8217;t see this option, that means your new database wasn&#8217;t selected in the menu before clicking the link to add a new user. Try again with your database selected.<\/p>\n<p>Next, click the <strong>Check All<\/strong> box under <strong>Global privileges<\/strong>, then click <strong>Go<\/strong> at the bottom of the page.<\/p>\n<div  class=\"wpdui-pic-regular  \">\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/09\/phpMyAdmin-gloabal-privileges.png\" alt=\"The create new user page\" width=\"670\" height=\"300\" \/><figcaption class=\"wp-caption-text\">Check the box to select all privileges or else your site won&#8217;t work.<\/figcaption><\/figure>\n<\/div>\n<h3>Importing Your Database Backup<\/h3>\n<p>When you see a message toward the top letting you know your user was successfully created, click on your new database in the menu, then on the <strong>Import<\/strong> tab.<\/p>\n<p>Click Choose file and select your database backup from your computer. All the default settings should be fine, but keep in mind that if the file doesn&#8217;t end in <code>.sql<\/code>, .<code>sql.zip<\/code> or <code>.sql.gzip<\/code> format, then select the correct one under the <strong>Format<\/strong> drop down box.<\/p>\n<p>Once you have selected your file, click on the <strong>Go<\/strong> button.<\/p>\n<div  class=\"wpdui-pic-large   \" >\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/09\/phpMyAdmin-import-database.png\" alt=\"Import page\" width=\"1364\" height=\"400\" \/><figcaption class=\"wp-caption-text\">Once you created a new database and username, you can import your database backup.<\/figcaption><\/figure>\n<\/div>\n<h3>Uploading Your Files<\/h3>\n<p>At this point, your database backup has been imported and now you need to upload your site&#8217;s files. Copy the uncompressed files to the folder where your test site is held.<\/p>\n<p>This is usually different for most local environment creating programs so consult their documentation if you&#8217;re not sure where you test site is located on your computer. You can also check out the links in the first section of this article.<\/p>\n<p>For single installs of WordPress, you should be all set. you can type in <code>localhost<\/code> into your browser to see your site. If that doesn&#8217;t work, check your software&#8217;s documentation for the correct link.<\/p>\n<p>If you had Multisite installed, there&#8217;s one final step before you can visit your site locally to test your WordPress\u00a0backup.<\/p>\n<p>When you have copied the files over to your local test site&#8217;s folder, open up the <em>wp-config.php<\/em> in a code-editing program and search for the following line a little before <code>\/* That's all, stop editing! Happy blogging. *\/<\/code>:<\/p>\n<div class=\"gist\" data-gist=\"4535e45352a98feccb5d5d3760eb6dd7\" data-gist-file=\"wp-config.php\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/4535e45352a98feccb5d5d3760eb6dd7.js?file=wp-config.php\">Loading gist 4535e45352a98feccb5d5d3760eb6dd7<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>Instead of seeing <code>your-site.com<\/code>, you should see your real domain. Replace that with <code>localhost<\/code> and save the file.<\/p>\n<p>You can go ahead and check out your site locally to test your WordPress\u00a0backup.<\/p>\n<h2>Testing Your WordPress\u00a0Backup with Snapshot<\/h2>\n<p>On your live site, install, activate and set up Snapshot Pro, then create your backup. You can check out\u00a0<a href=\"https:\/\/wpmudev.com\/blog\/backup-with-snapshot\/\" target=\"_blank\" rel=\"noopener\">How to Backup Your WordPress Website (and Multisite) Using Snapshot<\/a> and <a href=\"https:\/\/wpmudev.com\/project\/snapshot\/#product-usage\" target=\"_blank\" rel=\"noopener\">Snapshot Pro Usage<\/a> for all the details on that.<\/p>\n<p>Make a note of all the plugins you have installed on your site since you&#8217;ll need this information later.<\/p>\n<p>Create a fresh install of WordPress on a local or live site, then install Snapshot Pro there and set it up. Install all the plugin you had on your original site, but keep them all inactive.<\/p>\n<p>Go to <strong>Snapshot &gt; Import<\/strong> and enter the URL where your snapshot is located.<\/p>\n<div  class=\"wpdui-pic-large   \" >\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/09\/import-snapshot-pro.png\" alt=\"Import page\" width=\"1364\" height=\"400\" \/><figcaption class=\"wp-caption-text\">Import your snapshot so you can activate it to verify it works.<\/figcaption><\/figure>\n<\/div>\n<p>Next, click <strong>Scan \/ Import Snapshots<\/strong> and when you see a message letting you know the import was successful, go to <strong>Snapshot &gt; All Snapshots<\/strong>.<\/p>\n<p>You should see your snapshot listed. Hover over the name and click on the <strong>restore<\/strong> link.<\/p>\n<div  class=\"wpdui-pic-regular  \">\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/09\/restore-snapshot-pro.png\" alt=\"All Snapshots page\" width=\"670\" height=\"300\" \/><figcaption class=\"wp-caption-text\">Click to restore your snapshot and test it out.<\/figcaption><\/figure>\n<\/div>\n<p>On the next page, click the <strong>restore<\/strong> link under the snapshot&#8217;s file name.<\/p>\n<p>On the next page, go through the options and make sure they&#8217;re set correctly:<\/p>\n<ul>\n<li><strong>Restore Blog Options &gt; Site URL<\/strong> \u2014 Click the <strong>Change<\/strong> button if the URL of your test site is different, otherwise, skip down to the next section.<\/li>\n<li><strong>What Tables to Restore?<\/strong>\u00a0\u2014 Click on the button for\u00a0<strong>Restore selected database tables<\/strong>\u00a0and check <em>all<\/em> the boxes for all the tables listed that are dynamically displayed.<\/li>\n<li><strong>What Files to Restore?<\/strong>\u00a0\u2014 Choose the\u00a0<strong>Include selected files<\/strong> option, then check all the boxes for the files that are listed dynamically.<\/li>\n<li><strong>Restore Theme Options<\/strong>\u00a0\u2014 Check the box for <strong>Plugins &gt;\u00a0Turn off all plugins<\/strong>, then select the theme you want to activate.<\/li>\n<\/ul>\n<p>Finally, click the <strong>Restore Snapshot<\/strong> button. Pat yourself on the shoulder while you wait for your snapshot to percolate and when the process has completed, you can go ahead and test your snapshot to make sure it works.<\/p>\n<h2>How Often Should You Test Your WordPress\u00a0Backups?<\/h2>\n<p>Now that you can test your backups locally and with Snapshot Pro and you know why it&#8217;s important to test your backups, one question remains: How often should you test your backups to make sure they work?<\/p>\n<p>The answer to that question really depends on the frequency of activity on your site. If you don&#8217;t post often and you don&#8217;t receive comments regularly, you can probably get away with checking your backups less frequently.<\/p>\n<p>On the other hand, if your site flourishes regularly with your activity, it&#8217;s a good idea to verify your WordPress\u00a0backups\u00a0regularly and consistently.<\/p>\n<p>As a general rule of thumb, you can test your WordPress\u00a0backups once for every three or four backup cycles. If your backups are far and few such as every few months or once a year, it&#8217;s probably best\u00a0you test each of your WordPress\u00a0backups after they&#8217;re made.<\/p>\n<p>You can also look at it this way: Think about how long you can go without having to worry about losing content if your site broke and you had to restore it. This timeframe is good starting point to start considering the maximum amount of time you should go without testing your backups.<\/p>\n<p>With all things considered, verify your WordPress\u00a0backups as frequently as you deem necessary.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve used WordPress for a while, you know keeping regular backups can save you from losing your website (you know, the site you&#8217;ve put all that time and effort \u2013 literally hours \u2013 into building). But have you tested your WordPress backups to see if they actually work? Sometimes, backups could be missing files [&hellip;]<\/p>\n","protected":false},"author":54213,"featured_media":159415,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263],"tags":[829,10109,10789],"tutorials_categories":[],"class_list":["post-159239","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-backup","tag-restore","tag-testing-environment"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/159239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/54213"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=159239"}],"version-history":[{"count":30,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/159239\/revisions"}],"predecessor-version":[{"id":212068,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/159239\/revisions\/212068"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/159415"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=159239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=159239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=159239"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=159239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}