Support » Plugin: Quick Cache (Speed Without Compromise) » Rebuild database from wp-content/cache/ files

  • Resolved northrn



    I’m wondering if I can rebuild a DB from the files in the cache folder.

    If yes, where do I start/what are the steps?

    I’m starting from scratch, creating a new mysql DB at a new web host, and all we have backed up are the wp folders/files. Our old web host died, and we did request a tarball of the of DB from whatever servers may have survived, but no guarantees.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Raam Dev


    Hmm, that’s an interesting question. It’s certainly possible, since all the information you need should be contained within the cache files. However, it will require some careful scripting. If you’re not comfortable with programming, you might want to hire someone to do this for you.

    Since the current and previous versions of Quick Cache store the cache file as series of md5sum’s (e.g., qc-c-06f6ad591a050715528c482965594273-498611c9777da334ab82c2ff9cbe5311-c123dca94667c9376d1480e4785d83de), you’ll need to parse each cache file looking for the following string at the bottom of the cache file to figure out what the original permalink was:

    <!-- Quick Cache file built for ( in 0.68839 seconds, on: Apr 28th, 2014 @ 5:12 pm UTC. -->

    In this case, you know the original permalink was /sample-page/.

    Then, once you know the original permalink to that cache file, you’d need to extract the post content and the post title from the cache file (the cache file contains all the HTML for when the page was loaded, including stuff the <head></head>, navigation link HTML, sidebars, etc. Since you’re trying to restore the post content itself, you don’t want any of this other stuff. You only want the post content and the post title. (You could also extract Category and Tag info, but that would be extra work.)

    Whatever theme you were using when the cache file was written would determine the structure of the HTML.

    For example, the TwentyThirteen theme uses the following structure:

    <body class="page page-id-2 page-template-default logged-in admin-bar debug-bar-maximized customize-support">
    	<div id="page" class="hfeed site">
    		<div id="main" class="site-main">
    			<div id="primary" class="content-area">
    				<div id="content" class="site-content" role="main">
    					<article id="post-2" class="post-2 page type-page status-publish hentry">
    							<header class="entry-header">
    								<h1 class="entry-title">Sample Page</h1>
    							<div class="entry-content">
    								<!-- entry content goes here -->

    So you’d need to write a script that goes through the cache file and extract the post content and the post title based on the HTML structure of the cache files.

    Then you’d need to use the permalink information you gathered from the Quick Cache notes at the bottom of the cache file and insert a new post into a new WordPress database (probably using something like wp_insert_post()).

    I hope this helps!

    Yes, helps. Thank you for your detailed reply!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Rebuild database from wp-content/cache/ files’ is closed to new replies.