eta: There’s a better version of this now.
This is about 70% notes for myself because I have got to get back to work on my taxes, which I did not finish last weekend. It’ll also show you the lollertastic state of this code, even if it works just fine once you’re setup, and why I want to make it at least a bit better before posting it on github.
(I really didn’t think anyone would ask but I had two requests the first day, so.)
LET’S GOOOOOOOOOOOO
First, get an XML backup using this tool from the official dreamwidth github:
https://github.com/dreamwidth/dreamwidth/blob/main/src/jbackup/jbackup.pl
Second, set a whole bunch of resource allocations:
In [wp-home]/wp-includes/functions.php set runtime to 300 seconds max (default is 30 – and yes this is core code, deal with it) by adding this up top:
ini_set('max_execution_time', '300');
In /etc/php/[your version]/apache2/php.ini set runtime maximum to 90 seconds (default is 30):
max_execution_time = 90
and set process memory allocation limit to 1GB (default is like 132MB):
memory_limit = 1G
Using mysql console for MariaDB, increase maximum allowed packet size (default is 1:6777216)
SET GLOBAL max_allowed_packet=1073741824;
Now you’re ready to run. For the 2023/2/20 version of the code (fully functional but trainwreck version):
- Install the Livejournal importer plugin, if you do not already have it. (You probably do, I think it’s part of default install. It does not show up in plugins view, it shows up in tools/import. But it’s functionally a plugin.)
- Place the .xml of your downloaded journal in [wordpress-home]/wp-content/plugins/livejournal-importer (directory), name it tinytest.xml (as with many things, this will change)
- Because trainwreck, edit the .xml file to delete the <events> tag at the top of the file, and the closing </events> tag down at the bottom. This will also change.
- You will find livejournal-importer.php already existing in this directory. Replace it, using the same name, with the importer code. (You can just rename the original to go back.)
- In the WordPress administration view, go to Tools/Import and select Livejournal importer.
- Ignore the username and livejournal password fields, but DO enter a password for screened posts if you don’t want them to be public.
Click go and wait. Depending upon the size of your account, this could be a while. My 60mb journal (not counting images, they aren’t in the XML file) took around 12 hours of runtime.
If the import stops early:
Check to see what posts have successfully imported. Make sure they got all their comments, as well. Then edit the successfully imported posts out of the XML file and run the importer again. If you have one post where the post imported but the comments did not, keep it in the XML file and delete the half-imported version, it’ll be fine.
I don’t feel bad about this part because the official Livejournal importer does this same shit. Sometimes things just fall over. And also, standalone WordPress – particularly default config – just isn’t set up for this kind of massive import and you’ll both end up doing things it’ll regret. Kind of surprised by that, but there y’go.
The release version will be somewhat better? But it’ll still be stupid and fiddly like this, and you’ll need to have the ability to set those resource limits. Trust me on this, you’ll need to. (And it’s not just me. I found out about the MariaDB transaction resource lift by finding other people writing completely different importers saying you’ll need to for it to work.)
Okay. There’s that.
eta: see also this thread with denise and others on dreamwidth.
Posted via Solarbird{y|z|yz}, Collected.