Import 100mb content from other ghost installation

I’ve got Ghost setup, but want to import around 100mb of content.

Firstly I was getting an error saying that I couldn’t upload files that big. I edited my nginx config so that I could upload larger files
Then I was getting 504 timeouts, so I increased the timeout time with nginx

Now it sits in the importing state for a few minutes, then throws a 502 and “Uncaught Error: Request was rejected due to server error”.

How are you uploading the content? Using something like scp via CLI? Or are you running into the 502 error when uploading images individually?

Are you saying your JASON file is 100MB? I doubt that would be the case, because that would be one huge site. But you should be able to use SFTP to move your Content folder to the new location. What I would do is zip it first, move the zip file to the new server and unzip it in the proper spot. Import the JASON file from the Ghost editor in the Labs section and it should work.

I’m using the import tool on the labs section.

Yes the JSON file is 100mb, it is a huge site. I am using the import tool in the Labs section, it’s there that after 2 or 3 minutes after selecting the file and importing it that I’m getting the 502

Can you try importing via the Ghost-CLI? I don’t know that it will work, but it’s worth a shot:

ghost import {file}

Another thing to note is that the import shouldn’t stop running even if you run into a gateway timeout. I suggest taking a look at your Ghost logs to see if something’s failing

Was this JSON file generated by Ghost Admin’s export function? Is there any chance there’s an error in the JSON file? As @vikaspotluri123 suggested check your Ghost logs and let us know if you find anything.

So using Ghost logs (I was using Ghost run), I can see that when the request fails, it shows a post request with status code 200.

INFO "POST /news/ghost/api/v3/admin/db/" 200 120486ms

I did more investigating and looked at the nginx error logs

upstream prematurely closed connection while reading response header from upstream

Edit: Also, just to note, when I try to import staging data (a 10mb file), it works with no problems.

So once the POST request completes, are you missing any posts or data?

Although there is a 200 in the Ghost log, none of the data is transferred over. No posts or anything.

What are your timeout settings in your Nginx configs? Perhaps those need to be increased?

I already increased my timeout on nginx to 10 minutes.

This issue is solved now. I had to split up the JSON file. It’s a bit weird that it can’t handle a 100mb file, but basically I split the json posts into 4 separate files (I also had to upload the other properties with it, otherwise the posts wouldn’t have
authors or tags).

Ah glad you were able to find a solution. I wonder what the practical limit is on the JSON file size. I’ve been trying to find a way to automatically back up the JSON files along with my content dir and db dumps but after your experience here I wonder if it’s even worth it to try and back up the JSON export.

What did you use to split your JSON file?

1 Like

I just did it manually. Vscode couldn’t handle the large amount of JSON so I had to use something called ultraedit which is very lightweight (haven’t opened it since though).

It has built in formatting tools too so it’s easier to see what you’re dong.

1 Like

I ended up using sublime to edit manually. For mine I creased a series of files with the top and tail containing everything except for the post array. Then into each file I manually pasted a section of the posts. Appears to all have worked OK.