Last night, having tipped a small carafe of Grade 7 Burgundy into my greedy maw, I blithely reformatted my server and upgraded it to Meerkat, smug in the knowledge that I’d copied over /var/www and all the important config files first. However, suffering a lapse of judgement that would shame the greenest of noobs, I forgot to back up any of my databases, which meant I lost WordPress, my bookmarks page, my shopping cart, my site stats and quite a bit more. A doubleplusungood situation that I’ve been trying to rectify today. Still, at least it didn’t happen at work.
Turns out most of my extremely dull, derivative WordPress posts were available in my work rig’s Firefox disc cache (about:cache), though they were gzipped and unreadable, at least until I stumbled upon the excellent script below. I copied and pasted the relevant files’ contents, saved the lot as cache.log and then invited Chrome to fire it up. Having scrolled nervously through the resulting binary sea, I reached the output at the bottom and found the posts, perfectly intact. Many thanks to Frozax, who wrote it.
// cache.log is a copy of chrome or firefox cache page with
only the file content section
$cacheString = file_get_contents("cache.log");
print_r($cacheString);
$matches = array();
preg_match_all('/\s[0-9a-f]{2}\s/', $cacheString, $matches);
$f = fopen("t.bin","wb");
foreach ($matches[0] as $match)
{
fwrite($f,chr(hexdec($match)));
}
fclose($f);
ob_start();
readgzfile("t.bin");
$decoded_data=ob_get_clean();
echo $decoded_data;
The Wayback Machine helped me grab another couple of posts and trusty old Google had a cached copy of my bookmarks page, so at least I could restore them all manually. The cart schema sadly eluded me, but at least I had an Access sketch of the table relationships that roughly resembled the finished arrangement, so that’s now back in action.
Tomorrow’s task is to restore the posts and get Postfix working. Judging by the log message below, it should already be working, but my inbox remains void of contact forms. Time to consult a Unix expert.
19 18:40:08 MiffyServer postfix/qmgr[10735]: E188AAE0085: from=, size=569, nrcpt=1 (queue active) Jan 19 18:40:09 MiffyServer postfix/smtp[10810]: E188AAE0085: to= , relay=smtp.o2.co.uk[82.132.141.69]:25, delay=0.57, delays=0.09/0.01/0.31/0.16, dsn=2.0.0, status=sent (250 <4EEB66400530A52F> Mail accepted) Jan 19 18:40:09 MiffyServer postfix/qmgr[10735]: E188AAE0085: removed
Yes, my server’s called Miffy. I’m so sorry.