BAC Software Consulting Blog

How to Delete and Limit Post Revisions in WordPress

WordPress 2.6 and above has a new feature which is the posts and page revision. WordPress automatically creates revisions of your posts or pages. Whenever you save a post or a page, the old version is retained so you can revert back at any time. Older revisions are never deleted so you always have a full history of all changes. However, this feature causes your WP database to rapidly increase in size. Depending how active your blog is, revisions can seriously bloat your database with multiple copies of the same post. Each additional revision will slowly increase the size of your MySQL database.

Sometime it is necessary to do some cleanup. Every revision requires a separate record in wp_posts table and probably entries in the wp_term_taxonomy, wp_postmeta and wp_term_relationships tables. Removing older revisions will free up disk space.

Too many revisions stored in the database might cause longer query time. This means that your blog will load slower and your visitors may wait longer before the content loads. This also leads to high CPU or memory load on your Web hosting server. To my shock, I realized that in this blog I have anywhere from 9 to 47 unnecessary revisions per post/page. Wow!

Does reducing the database size, also speeds up your Website load time?

As you can see from the above image, removing old revisions is one of the best things you can do to your WordPress blog to keep it running efficiently. For a personal blog, many versions of the same post is a waste of resources. Excessive revisions will increase the burden on the database, slows down your WP admin area, your phpMyAdmin and may slow down the download time of your WP Website.

WP Revision Options

The WP_POST_REVISIONS constant has 3 options.

  1. true (default), -1: store every revision
  2. false, 0: do not store any revisions (except one for auto save)
  3. (int) > 0: store that many revisions (+1 auto save). Old revisions are automatically deleted.

Deleting Existing Revisions Using SQL command

Before we start, I am going to say this once: BACK UP YOUR DATABASE. You are about to run SQL statements to your WP database, and if you make a mistake you can revert back to your backup version.

To permanently delete all existing revisions for all pages and posts, login to your phpMyAdmin, select your WordPress database, click on the “SQL” button and paste the following code in the SQL command window. For a detailed explanation about SQL command1, the tutorial is in the References section at the end of this post.

SQL command1:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( b.term_taxonomy_id = d.term_taxonomy_id)
WHERE a.post_type = 'revision'
AND d.taxonomy != 'link_category';

My WP Database After Executing SQL command1

After executing SQL command1I noticed that NOT all stored revisions are deleted in the my WP database. Checking the post_type field in the wp_posts table, I noticed that there are still many “history” data that have not been removed. It seems that the above code still leaves some traces behind. This brings me to the execution of the next SQL command2.

To better explain, the wp_posts table has a field named post_type. This field can have many values, such as post, page or revision. When we want to get rid of all revisions, we run a SQL command to delete any entry in the wp_posts table in which the post_type field is equal to revision.

Again, in your phpMyAdmin area, click on the “SQL” button, and paste the following code in the SQL command window, and hit Go.

SQL command2:

DELETE FROM wp_posts WHERE post_type = 'revision';

My WP Database After Executing SQL command2

Now after executing SQL command2, all previously saved revisions stored in the WP database are totally removed. There are no orphaned data left in the database.

The following table shows my WP database before and after executing SQL command1 and then SQL command2.

 table: wp_posts
(Records)
table: wp_postmeta
(Records)
table: wp_term_relationships
(Records)
Database size
(KB)
Database reduced by:
(Compared to Baseline)
Baseline
(Before Executing the SQL commands)
7892154947,558n/a
After Executing SQL command14162151214,99333.93%
After Executing SQL command24421512150993.26%

Wow! After executing SQL command1 and then SQL command2, the size of the database has been reduced by 93.26%, and the wp_posts table has now 44 records down from 789 records originally. That would tell you how much the WP revision feature can accumulate unnecessary records in the database. Now the question that comes to mind is how to prevent or at least limit the number of revisions in WordPress?

Disable or Limit Revision feature in WordPress

To Disable WordPress Post Revisions:

You can turn off post/page revision feature by editing your wp-config.php file located in your WordPress root directory. Simply add the following code at the top of the wp-config.php file:

//Turn OFF WP revisions feature. 
define('WP_POST_REVISIONS', false);

You could put the code above anywhere at the beginning of the config file as long as it is inside the opening PHP tag (<?php)

To Limit WordPress Post Revisions:

Alternatively, you can use a positive integer to limit the number of revisions.

//Limit WP revisions. Value can be any positive integer number.
//Create a maximum of 2 revisions, plus one for auto-save.
define('WP_POST_REVISIONS', 2);

What About Website Loading Speed?

After the size of the database has been significantly reduced (93% in my case), I noticed that:

  1. WordPress administration area is faster to load and to respond to user requests.
  2. phpMyAdmin area, where the WP database reside, is faster to respond to user requests.

But the biggest question I have: Did deleting WordPress post and page revisions have any impact on this Blog loading speed?

Does Deleting Post and Page Revisions Speed up Your WordPress Website?

I would say that the improvement of this blog´s download time is statistically insignificant. What remains to be seen is that if you have a much larger database with hundreds of posts, would that make a significant difference?

DoFollow Versus NoFollow What to Choose for Your Website?

DoFollow and NoFollow are important factors for SEO that influence the ranking of a particular Website in search engines. DoFollow is a term that does not exist. It is a term given to Websites that are not using the rel=“nofollow” attribute in links. nofollow is a value that can be assigned to the rel attribute of the HTML link to instruct some search engines not to pass on any influence to an outbound link. NoFollow and DoFollow control how a Website passes its PageRank or link juice to other links.

Although search engines don´t pass along the link juice (or let PageRank flow) they still follow and index these links. The nofollow value is not meant for preventing content from being indexed by search engines.

What Exactly is NoFollow?

NoFollow (rel=“nofollow”) means that PageRank or Link juice will NOT be passed to a link. It tells major Search Engines, especially Googlebot, that this link can be followed, the linked page is crawled and indexed, but the PageRank score will not be taken into account.

The attribute that defines a link as NoFollow is rel=“nofollow”.

A typical NoFollow link is like this:

<a rel="nofollow" href="https://bacsoftwareconsulting.com/" title="">BAC</a>

What Exactly is DoFollow?

DoFollow is the exact opposite of NoFollow. A DoFollow link will let your PageRank flow to all external and internal links. When you remove the rel=“nofollow” attribute from a link, then the link becomes DoFollow. The absence of the nofollow value makes the link a DoFollow. Search Engines robots, especially Googlebot, will crawl the link, index it and the PageRank score will be taken into account.

A typical DoFollow link is like this:

<a href="https://bacsoftwareconsulting.com/" title="">BAC</a>

How Do I Know if a Website is Using NoFollow?

There are 2 ways to check:

  1. View the Source code: Highlight the link that you want to check and view the source code of the Webpage. There are several ways to To view the page source depending on the browser you use. You could either select “source” from your browser´s menu or you could right click on the page to view the source from the context menu.
  2. Use an Add-On: Mozilla Firefox and Google Chrome browsers have add-ons that highlight a NoFollow link on a Webpage without actually looking at the source code.

Advantages of rel=“nofollow” Attribute

  1. Minimize Comment Spam: Especially the comment spam that is manually filled by real users once they know that your Website is DoFollow. Automatic spam will not be affected. Robots that submit spam will not check your link status.
  2. Not Passing on Your PageRank:You might not want to pass your PageRank to Websites that are completely unrelated to your field, as this, with time, may cause your PageRank score to go down.
  3. The overall PageRank of your Website is preserved.

Disadvantages of rel=“nofollow” Attribute

  1. You will not attract more visitors to comment on your Website, thus getting less traffic.
  2. Without improving popularity, you may not get inbound links to your Website. Thus your PageRank will not improve.
  3. Less traffic, means less clicks to any advertisements you have on your Website, and thus less earnings.

Where Should I use rel=“nofollow” Attribute

Use the rel=“nofollow” attribute whenever you don´t want to pass your link juice. Regardless what you read otherwise, never add nofollow to any internal pages of your Website. Here are some scenarios when to use NoFollow:

  1. Use NoFollow for single pages that has more than 100 links. For example, a resource page having several hundred links.
  2. Use NoFollow for Trust Badges: like the Better Business Bureau and VeriSign, you can add rel=“nofollow” to those links.
  3. Use NoFollow for your RSS feed. This ensures that your RSS feed isn´t indexed before your Website.
  4. Use NoFollow when linking to any “questionable” and untrusted Websites.
  5. Use NoFollow for mega Websites and Social Networks such as: Facebook, Gmail, Adsense, etc.
  6. Use NoFollow if you link to Web browsers such as Mozilla and Chrome.
  7. Use NoFollow for paid advertising. If you sell advertisement space on your Website, those ads should always have a rel=“nofollow” attribute inserted in the Link.
  8. Use NoFollow for affiliate links.

Is NoFollow a Bad Thing?

No not necessarily, consider the following: The NoFollow links might have no effect on PageRank but they still refer real people. As long as “real visitors” can follow the links, that´s great. Eventhough you do not get link juice from the NoFollow links, you still get real visitors.

NoFollow isn´t bad. There´s nothing wrong with getting NoFollow links. While they don´t pass link juice, they do help associate your Website with anchor text.

Advantages of DoFollow

The advantages of adding DoFollow links on your Website are:

  1. You will attract more visitors especially for comments, thus getting more traffic, exposure and popularity.
  2. With an increase in popularity, you may get more inbound links to your Website, which helps your PageRank to increase.
  3. The increase in traffic may also increase your revenue from affiliate programs and other advertisements.

Disadvantages of DoFollow

  1. The PageRank of your Webpage will be passed to external links. The overall PageRank can be reduced.
  2. However, you can offset the decrease of your PageRank by attracting more inbound links.
  3. You get an increase of spam Comments, which require extra time and efforts from your side.

Which Links Should be Set as DoFollow?

To reemphasize, the non-existence of the rel=“nofollow” attribute, means that the link is DoFollow. Links that should be kept DoFollow are:

  1. All Internal Links. Internal links will help spiders crawl your pages more deeply and they will get indexed often.
  2. For a blog, links pointing to posts should be kept DoFollow.
  3. Niche links can be DoFollow. Always give a link to a Website that shares the same content as yours.

Why Blog Owners Abandon DoFollow?

The answer is simple Comment spam. Spam does not have to be automated. A person can leave just as many worthless comments as software just to get link juice. For every person who takes the time to make a genuine comment, there are several who do the following:

  1. Leave a trivial comment.
  2. Leave a short summary of the Post.
  3. Leave a flat out spam comment unrelated to the topic.
  4. Leave spam comments on several posts in one session.

Conclusion

  1. Ultimately, as long you keep providing great content and services that people want, your Website will grow.
  2. Whatever your decision is, just remember that one “authoritative” link can be more effective than several low level links.
  3. You can build relationships through commenting. Leaving thoughtful comments is a good way to start a relationship with an influential blogger in your field.
  4. Remember that DoFollow blogs are giving you link juice in exchange for your quality comments. So, be considerate. If you post junk comments, blog owners will get tired of moderating and taken advantage of, and will eventually turn NoFollow back on.

So What would I choose? The best approach is to use a mixture of DoFollow AND NoFollow links.

A Closer Look At HTML Versions

HTML has evolved into one of the most used and highly recommended markup languages. Web developers, both amateurs as well as professionals have tremendously benefited from the emergence of HTML. The frequent release of different HTML versions reflects the growing popularity of the language. Through this post, I will be familiarizing you with different versions of HTML which have created a wave in the world of web development. So, let’s examine each of these HTML versions closely.

1. First Version – HTML

Well, the very first version of HTML didn’t come with a number. IT was just called “HTML” and was solely used for creating simple web pages. Marking its use way back in 1989-1995, this first version of HTML was later standardized by IETF and numbered as “HTML 2.0”(explained under point no.2 below).

2. Second Version – HTML 2.0

Considered as the very first definitive HTML version, the initial draft of HTML 2.0 was being re-written and revamped by Karen Muldrow in July 1994. After this, it was being presented at an IETF meeting in Toronto. The sole purpose of this draft was to capture the most common HTML practice in web browsers. Some of the features absent in HTML 2.0 include: support for tables or ALIGN attributes, Netscape/Microsoft extensions etc.

3. Third version – HTML 3

Released back in late 1995, HTML 3 was a result of the tireless efforts put in by Dave Raggett who was inclined on upgrading the features and utility of HTML. Although this version was never implemented, a majority of its features were being integrated in HTML’s next official version which was known as HTML 3.2.

Version 3.2 of HTML came equipped with an integrated support for images, Tables, heading and a variety of element ALIGN attributes. Serving as the current “universal” dialect, HTML 3.2 could be understood by all the major browsers. However, some features which went missing in HTML 3.2 comprised of EMBED, FRAMES and APPLET. This HTML version was being presented by World Wide Web Consortium (W3C) in the year 1997. Published in January 1997, HTML 3.2 included attribute alignment, tables, headings, images and a lot more.

4. Fourth Version – HTML 4.0

Considered as the next major release of HTML, version 4.0 was introduced in December 1997. As an extension to its existing feature set comprising of multimedia, text and hyperlink, this version of HTML included advanced multimedia options, style sheets, scripting languages, improved printing facilities and documents, which are accessible to users with specific disabilities. This version of HTML has also taken stride towards the internationalization of documents, with the sole aim of ensuring maximum evolution of the World Wide Web.

HTML 4.01

Yet considered as another official release of HTML, the version 4.01 includes support for a majority of extensions in addition to features such as extra TABLE, JavaScript enhancements, support for internationalized documents, FORMS and Cascading Style Sheets. Released in December 1999, HTML 4.01 was being presumed to be replaced by a brand new language called XHTML-Extensible HyperText Markup Language. Recognized by all the modern browsers, HTML 4.01 serves as the perfect option for building an intranet where the browsers support just the 3.2 or 4.0 tags. W3C has always been recommending that authors and user agents prefer producing HTML 4.01 documents instead of HTML 4.0 documents. In addition to this, W3C also recommends that the authors must generate HTML 4 documents instead of HTML 3.2 documents. Last, but definitely not the least, W3C recommends that all the tools which are interpreting HTML 4 must continue supporting both, HTML 2.0 and HTML 3.2.

5. Fifth Version – HTML 5

Assumed to be the last HTML version, HTML 5 was released in January 2008 and was published as a W3C Recommendation on October 2014. Equipped with its own HTML serialization, HTML 5 has a syntax which reminds us of the very popular SGML syntax. Plus, this HTML Version also comprises of an XML that’s based on XHTML5 serialization. Although HTML5 isn’t fully supported by some older browsers, there are polyfills which can easily use JavaScript for making specific features work in these browsers. For instance, html5shiv uses JavaScript for allowing older IE (Internet Explorer) versions to recognize and style specific HTML elements.

Conclusion

So now that you know all the different versions of HTML, it is up to you to make a wise choice in accordance to your requirements. Hope the information provided above would enlighten you to take a good decision.

5 ways to Enhance User Experience

Today where internet is flooded with many options for web users, online businesses has changed their motive to keep their visitors interested rather than increasing sales. The better the user experience on the website, the better the chances of growing in the market. In order to make your online business a big hit, it is important to make your website user-friendly.

What is considered for making a website user-friendly? Is it the amount of information we offer on our website? Or how beautiful it looks? Though these two are considered important, there are many other factors that will definitely persuade your visitors in a positive way.

Here are 5 ways to enhance User Experience for your website:

But First, What is User Experience?

According to Wikipedia: User experience (UX) involves a person’s emotions about using a particular product, system or service. User experience includes the practical, experiential, affective, meaningful and valuable aspects of human-computer interaction and product ownership. Additionally, it includes a person’s perceptions of system aspects such as utility, ease of use and efficiency.

1. Implement Responsive Design

Responsive web design has been creating a buzz since its introduction. You probably have seen many websites making use of this new technology to drive more traffic to their website. Responsive design is no longer an option; it has become the need of the hour. Whether you already have an online presence or planning to build one, responsive layout is not something you can overlook in today’s world.
Responsive layout is a website design approach intended to craft websites to offer the best possible viewing experience to the user — easy navigation and reading with a minimum of scrolling, panning and resizing — over a wide range of platforms (from personal computers to smartphones).

2. Add Interactive Elements

Nearly every business is user-oriented. As they say “customer is king”, getting the attention of your visitors in the first few seconds is necessary to keep them interested in your site. Presenting interactive elements in front of your visitors gives them an opportunity to communicate with the site directly. Don’t make them wait for something they badly want, instead try to offer them options that address their needs. You can add infographics, a combination of content, images, videos, colors and movements, to make your content more interesting.

3. Get Feedback from your Visitors

Feedback is a great way to improve your website and services. You can either create one feedback page or simply make use of third party tools to get the valuable feedback on your website structure, design, page loading speed and appearance from your visitors. You can even install certain WordPress plugins like YOP Poll, Opinion stage, and Feedweb to know your visitors reviews.

4. Keep Social Media Registration Options

Nobody likes to register to a website. Adding social media registration option such as twitter, Facebook, and Google+ makes it easier for visitors to register and read your valuable content. You can even add Disqus and Facebook comments option to improve user interaction on your website.

5. Don’t use Newsletter Signup Pop-up

Let’s face it; we hate it when pop up comes up now and then while reading something on the site. These newsletter pop ups literally suck! I get it, you just want to produce some sales leads but it only increases the bounce rate of your website. Believe me, don’t ever use it. It is just not worth the time and effort!

Bonus! Other Techniques to Enhance User Experience

There are many more techniques to enhance User Experience (User Experience for the Web (WebUX) is a field on its own), such as:

  • Use a Consistent Design.
  • Optimize Graphical Elements.
  • Easy and Intuitive Navigational Structure.
  • Provide a Search Mechanism.
  • Short (to the Point) Registration Forms.
  • Place Important Information above the fold.
  • Use Breadcrumb Navigation.
How To Turn Your WordPress Blog From NoFollow to DoFollow Without a Plugin

How To Turn Your WordPress Blog From NoFollow to DoFollow Without a Plugin

In this tutorial, I will show you how to easily turn your WordPress blog from the default NoFollow to a DoFollow blog without the need of a plugin. Why not turn your blog into a DoFollow blog and get more visitors, more traffic and eventualy more recognition in the Online community. Probably you already have seen some blogs displaying the DoFollow image and you wonder how it is done and what it really means. Read my next tutorial for a closer look at DoFollow versus NoFollow.

What are NoFollow and DoFollow?

DoFollow is a term that does not really exist. It is a slang term given to Websites that are not using nofollow. nofollow is a value that can be assigned to the rel attribute of the HTML anchor tag to instruct some search engines not to pass on any influence to an outbound link. The nofollow value was intended to stop comment spam in blogs. Commenting is recognized as a good way to get one way backlinks. But it has been abused and thus the creation of the nofollow value back in 2005.

You might already know that NoFollow blogs do not carry any PR value to other Websites through commenting. If your blog is DoFollow then comments made by your users get Link juice, meaning that your blog passes on the PR value to the commenter.

Should You Set Comment Links To DoFollow?

One way to encourage your readers to comment on your blog is by making your blog DoFollow. If your blog is new and you are trying to increase traffic then you need to turn your blog to a DoFollow blog. When people comment on your content they are adding value to your content. Some consider DoFollow as bribing visitors for comments, while others consider it as rewarding visitors that leave a comment. I tend to agree with the latter, but whatever your opinion is, DoFollow encourages interaction with your readers. One negative side though is that it increases comment moderation duties and an increase of spam comments.

What About a Plugin?

Yes, there are several plugins that turn your blog to a DoFollow blog. But I encourage you to read my previous article about unnecessarily adding plugins to your theme. Also, you really don´t need a plugin for such a simple task.

How does NoFollow and DoFollow Look Like?

The only way to know whether a link has been set to NoFollow is to look at the source code of the page. There are several ways to do that depending on the browser you use. To look at the source code, select “source” from your browser´s menu or you could right click on the page to view the source from the context menu. Also, Mozilla Firefox browser has add-ons that highlights a nofollow link on the page without actually looking at the source code.

The attribute that defines a link as NoFollow is rel=“nofollow”. If you remove the rel=“nofollow” attribute, then your link becomes DoFollow. There is no dofollow value. The absence of the nofollow value makes the link a DoFollow.

A typical DoFollow link is like this:

<a href="https://bacsoftwareconsulting.com" title="">BAC</a>

A typical NoFollow link is like this:

<a rel="nofollow" href="https://bacsoftwareconsulting.com" title="">BAC</a>

Features of My “DoFollow” Code

  1. The code is added to your theme´s functions.php file. The core WordPress code is not modified in any way.
  2. The code is split into 2 independent sections (Section1 and Section2). You have the choice to choose either one or both.
  3. The code is tested to work with the latest version of WordPress. However it also works with earlier versions.
  4. The code is tested to work properly with all major browsers.

“DoFollow” Code | functions.php

To change your Comment links from NoFollow To DoFollow, Open the functions.php file located in your theme´s folder, and add (copy and paste) the following code.

Note: To scroll within the code: You can also click on the code window and use your keyboard´s arrow keys.

<?php
/**** Section1: Changes the author's link in the comment section to a 
'dofollow' instead of the default WordPress  of 'nofollow' ****/
function dofollow_comment_author_link() {
    $url    = get_comment_author_url();
    $author = get_comment_author();
 
    if ( empty( $url ) || ('http://' == $url))
        return $author;
    else
        $link = "<a href='$url' rel='external' class='url'>$author</a>";
        return $link;
}
//http://codex.wordpress.org/Function_Reference/add_action
add_action('get_comment_author_link', 'dofollow_comment_author_link');
/* End of Section1 */
 
/**** Section2: Changes all links in the comment text to a 'dofollow' 
instead of the WordPress default of 'nofollow' ****/
function dofollow_comment_text_link($string) {
    //http://www.php.net/manual/en/function.str-ireplace.php
    $string = str_ireplace('rel="nofollow"', '', $string);
    return $string;
}
//http://codex.wordpress.org/Function_Reference/add_filter
add_filter('comment_text', 'dofollow_comment_text_link');
/* End of Section2 */
?>

“DoFollow” Code Notes:

Note: If you don´t see the horizontal bar, and to scroll within the code, you can also click on the code window and use your keyboard´s arrow keys.

1. Section1 of the above code changes the author´s link in the Comment section to a dofollow instead of the WordPress default of nofollow.

Meaning an Author´s link such as:

<a class="url" rel="external nofollow" href="https://bacsoftwareconsulting.com">BAC</a>

will be transformed to:

<a class="url" rel="external" href="https://bacsoftwareconsulting.com">BAC</a>

2. Section2 of the above code changes all links in the Comment text to a dofollow instead of the default WordPress of nofollow.

Meaning Any link in the Comment text box such as:

<a rel="nofollow" href="https://bacsoftwareconsulting.com">BAC</a>

will be transformed to:

<a href="https://bacsoftwareconsulting.com">BAC</a>

3. You have the choice to apply either Section1 of the code or Section2 or Both. For this Blog, I applied both Sections.

General Warning

When you add several PHP code blocks in your theme´s funtions.php file, make sure that you do NOT leave any white space (spaces, newline) before the opening PHP tag or after the closing PHP tag. Like so (the correct way):

<?php 
//Some Code here beetween the opening PHP tag (above) 
//and the closing PHP tag (below)...
?>
<?php 
//Some other Code here ...
?>

In the above code, if you leave any white space or a newline between lines 4 and 5, you will get the following error: Warning: Cannot modify header information – headers already sent by … , in your login screen and after you login to your WordPress dashboard.

Your Turn to Talk

What is your opinion about NoFollow or DoFollow? Does link juice mean anything to you? How easy did you find this tutorial to implement?

If you have something to say, please share your opinion in the DoFollow Comment section and get your reward. Your opinion matters, unless it is a Spam. By the way, this blog is now a DoFollow blog.

Complete Backup of Your WordPress Website in 2 Simple Steps

Complete Backup of Your WordPress Website in 2 Simple Steps

In this tutorial I will show you a 2 step process for a full backup of your WordPress Website. This is an important task as discussed in Tip3 of my previous tutorial about WordPress Security. This tutorial mainly focuses on manual backups of self-hosted WordPress Websites.

Why Backups are important? Because you cannot depend on your Web host to keep a current backup of your Website. Also, you can protect your Website from crackers by making regular WordPress backups. Making backups is essential because problems inevitably occur and you need to be in a position to recover fast.

A complete WordPress backup is not difficult if you know what to do. Your WordPress Website consists of two parts: Database and Files. Therefore, for a complete backup, you need to backup your WordPress database AND your WordPress Files.

Step1. Backup your Database using phpMyAdmin

Your WordPress Website is powered by a MySQL database which contains all of your content and the settings for your Website. If your database gets damaged or erased your Website would be like an empty shell without content. Your database needs to be backed up separately from your WordPress files.

I strongly recommend that you backup your database regularly and before any upgrades. Restoring your database from a backup is then possible if something goes wrong.

To create a backup copy of your WordPress database, you can do that from your phpMyAdmin Web interface using the Export function. How to do that?

  1. Log into your phpMyAdmin
  2. Select your WordPress database
  3. Click on the Export tab on the top set of tabs
  4. Look at the top left box of the Export section. All the database tables you selected are in that box.
  5. WordPress tables usually start with “wp_” or whatever table_prefix you specified in your wp-config.php file.
  6. If you only have your WordPress blog installed in that database, make sure to “Select All” unless you are making a custom backup for a specific purpose.
  7. Ensure that the SQL radio button is selected.

For the Structure section

Check the boxes as shown in the image below.

For the Data section

Check the boxes as shown in the image below. Complete inserts and Extended Inserts are mostly cosmetic changes to the output style, though Extended Inserts can help if you are having issues with the file size.

  1. Check None for compression. If your database is very large use any compression option.
  2. Keep remember template checked.
  3. Now click Go and save the file to your computer.
  4. You have now backed up your database.

See the image below:

REMEMBER: You have NOT backed up the files and folders (like images, videos, etc.), but all your posts, comments and WordPress settings are now safe.

What does "Add DROP TABLE / VIEW / PROCEDURE / FUNCTION" do?
It will drop (remove) the existing tables before recreating them again. This ensures that the tables creation is successful. If you don´t check this box you may need to drop the tables that you want overwritten before importing the database.

References:

  1. Backing Up Your Database
  2. WordPress Backups
  3. Using phpMyAdmin
  4. phpMyAdmin

Step2. Backup your Files

The database content is not enough for a complete backup, you also need to backup your files. In general a WordPress Website consists of several components:

  1. Core WordPress files
  2. WordPress Plugins and Themes files
  3. Your other specific files (images, videos, audio, custom files, etc.)

All of these components are used to generate your Website. These need to be saved.

Since you can always obtain the core WordPress files from the WordPress Website. At the least you need to backup the wp-content folder and all its content. This folder contains your theme(s), your plugins, all your uploads, and any custom files you have. Besides the wp-content folder, there are 2 other files that you should also copy which are: wp-config.php file and the .htaccess file (if it exists). My advice to you is to also include the core WordPress files. This ensures that you have a complete backup of everything related to the structure of your WordPress installation.

Using an FTP program, such as FileZilla, you should backup your WordPress files by downloading them to a folder on your computer or to an external drive. This step will only work if you have a self-hosted WordPress Website.

Remember that this type of backup does not backup your posts, comments and other associated data. You must also backup your database as discussed in Step1 above. Also keep 3 backups of the files, just in case one gets corrupted or lost, and store them in different places.

References:

  1. Backing Up Your WordPress Files
  2. Using FTP Clients
  3. Using FileZilla

Other Options

The required steps for a complete WordPress Backup are Step1 and Step2 listed above. Here, in this section, I want to give you other alternatives that might help.

WordPress Export Function

This is an XML file that you can save for the purpose of importing it into a new WordPress install. This file is helpful and makes it easier to move your Website hosted in WordPress.com to a self-hosted WordPress installation.

From your WordPress dashboard, go to Tools -> Export and download an XML file of your Website’s content. This file, contains your posts, pages, comments, custom post types, categories, tags, and users. However, with this file you do not get all of your media backed up with it. While it is an easy backup, it is by no means complete. Once the Export file is created, it can be imported using the Tools -> Import SubPanel in WordPress dashboard.

This XML file is not a replacement of your WordPress database backup as discussed in Step1. It does not create your database tables and does not backup your media and structure files as discussed in Step2. Consider this file as an additional, sometimes useful and helpful backup. So you could add this, as I do, to your routine backup strategy.

Automatic Backups

There are few WordPress plugins that automatically backup your WordPress database and some plugins also backup your WordPress files. However, I can´t vouch for any of them because I have not tried them. Feel free to try them and give us your feedback in the comments section. It is much easier for me to take the manual approach, I like to keep plugins at a minimum.

Typical Questions

How often should I backup?

You should backup on a regular basis, daily or weekly depending how active your Website is. Also, if possible, backup to a read-only media to ensure that your files have not been tampered with.

A sound backup strategy includes keeping a set of your entire WordPress installation (WordPress core files and database) in a trusted location. How many backups should I keep?

Most people make one backup and then overwrites it every time. But this is the wrong approach. A rule of thumb is to keep at least three backups and keep them in three different places. My database backup is huge. What can I do?

Often statistics and anti-spam plugins can add large amounts of data to your database. When backing up the database, this information is not important to keep. Do not select those tables during the backup process.

Conclusion

To have a full backup of your WordPress Website all what you need is implementing Step1 AND Step2. If you don´t take backups seriously, you might one day find out the hard way when your entire Website is gone.

Also regular backups, is one important factor in your Website´s overall security strategy as I discussed in my previous tutorial.