So, I migrated my ghost blog from an old DO droplet to a new instance, and I failed to restore all of the images...

I spun up the new server, imported my theme and content, and updated DNS. I checked the site and made a few tweaks to the theme and code.  Everything looked good.  Posts were there, images and links were working, so I deleted my backups, killed the old droplet, and moved on with my life.  

Well, until today.  Turns out that all of my images were just cached copies on Cloudflare's edge.  Once that cache expired, no more images (sad-town).  What had happened was the Ghost import process pulled in all of my posts, but failed to pull in the images (because that's not part of that process, apparently).

So, now what? My old droplet was gone and the volume was no longer accessible, and my local backup was also gone.  Way Back Machine to the rescue!  I checked and there was a fully backed up version!

Ok, so problem 2: how do I pull down all of the images for all of my blog posts from their cached copies?  Well, due to how they render out the cached copy, turns out I can scrape it via python :)

So here's the quick and dirty python script I wrote up to scrape the latest snapshot of my blog on web.archive.org:

Once I was able to pull down everything and store it in the same directory format as my blog (love how Ghost does that), I copied it over to my server via putty scp (pscp) using the recursive flag and BAM.  Like magic, the images are back!

Good times on a busy Saturday.