I see a lot of posts on taking Backups of your Wordpress Websites, But Restoring them still needs guidance, and most of the people don't know how to do it.
Now in most of the cases, Your Host will help you to restore your website. But in case they don't, follow this guide.
To Restore a Wordpress Website or any Website in General, You need two things -
- Files and Folder for the Website in a proper Structure
- How to extract them from a Zipped Backup?
- A lot of people, Use cPanel's Full Backup Feature in which you get a tar.gz with a name like "backup-Date/Time_yourcPanelusername.tar.gz." Or if your Host generates it using SSH, It will be in the "cpmove-yourcPanelusername.tar.gz." Format.
To extract your Files and Databases from this Zip, Just Extract that File, You'll get a .tar zip. Extract it again, and you'll get a list of Files and Folders.
Now in this big list, All you need is - "homedir" and "mysql", to restore your website.
Now go inside HomeDir and Copy the contents of the "public_html" Directory. These are your Files and Folder for the Website in a proper Structure.
Now, Locate the wp-config.php File(For Wordpress) and Look for the DataBase Name Inside that file. It will be in the following Format "define( 'DB_NAME', 'database_name_here' );"
Once you have the Database Name, You can go to the "mysql" folder in your extracted backup and look for the file "database_name_here.sql" File.
Now, this is your Website's Database.
- From any other backups types, You'll need to find the same things. First locate the Wordpress Directory Structure which usually consists "wp-admin,wp-content,wp-includes,wp-config.php" Once you locate the Directory in which all these files are located. Store them at a safe Place.
Find your Database Name from "wp-config.php" and Search for the file "database_name.sql".
- How to Restore your Backup inside cPanel?
At this Step, I am assuming that your cPanel has this domain configured as Primary or Addon Domain and Nameservers are pointed Properly.
Login to Your cPanel, Locate the "File Manager" Option, Click on it and Select the following options.
Once you're inside the File Manager, Upload all the files you got inside the "homedir/public_html/" directory from the Backup.
Congratulations! You've successfully uploaded Files and Folder for your Website in a proper Structure.
Leave the File Manager Open and Come back to cPanel.
Now Search for the MySQL Databases option inside cPanel.
Create a DataBase with your Desired Name.
Now Scroll Down,
Create a MySQL User, It is NOT required to keep MySQL Username same as Database Name. For Security Reasons, it is recommended to keep them different.
NOTE - Remember the Password.
Now, Little bit More Scrolling,
Select your DataBase and User your Just Created, And Click on "Add".
Check "ALL PRIVILEGES" And Click on make Changes.
Selecting "ALL PRIVILEGES" is fine unless there are specific instructions about your application. For WordPress, "ALL PRIVILEGES" is just Fine.
Remember the File Manager we left Open? Now's the time to use it.
Locate the wp-config.php File again, Click on Edit and Edit the Following Parameters -
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
DB_NAME is the Name of Database you just created, and UserName and Password are the MySQL Username/Password you just configured and gave them access to your DB.
DB_HOST will be localhost in 99% cases. If your Host hasn't specified any DB_HOST, Go Ahead with "localhost"
Once this is Done, You can Safely Close File manager.
Now, Remember The .sql file we found? The Website's DataBase. It's time to Restore it.
Go back to your cPanel and Search for the option "phpMyAdmin".
Inside phpmyadmin, On the Left Side Search for the Database you created and click on it. Then Click on "Import".
Now, Choose your .sql file, Scroll Down and Click on Go.
Uploading may take some time depending on your Website size. Wait for the following message -
Now You can safely close cPanel and phpMyAdmin Tab.
- In Other Panels, Method will be exactly same except that the terminologies might change. For a Server having Only Command line access, You can restore your files inside the directory you define under Apache/Nginx vHost and install phpmyadmin on your server to create the database and restore it.
Congratulations! You've successfully Restored your Wordpress Website.
I hope this helps Let me know if you guys find any issues restoring your backups. And I apologize if there are any unknown mistakes in the above tutorials, Suggestions to improve are always welcome