Copy content entry to another space

Hi guys,
our content managers have a playground space, where they enter articles for example, normally just for testing. But sometimes the articles entered in the playground space need to be transferred to the live space. Is there a way to export only one specific entry and to import it to another space?
Thanks,
Thomas

Hi Thomas,

That is possible with our export and import tools.

In the export tool, you can specify a single entry using the queryEntries parameter:

In your case, you can use something on the lines of

queryEntries: [
    'content_type=<content_type_id>',
    'sys.id=<entry_id>'
  ]

Hi Gabriel,
thanks for your quick answer. I just executed the following command in the CLI using Contentful-export version 7.2.0:

contentful-export --space-id --management-token --query-entries β€˜sys.id=’ --content-only

The result shown was:

───────────────────┐
β”‚ Exported entities β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€
β”‚ Entries β”‚ 1 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€
β”‚ Assets β”‚ 721 β”‚

Actually I expected, that only the assets from this entry were exported. Instead it all assets were exported. Is there are way to only export the assets of the queried entry?

Thanks and best regards,
Thomas

1 Like

Hi @thomas.niessen,

I have just tried this in my end and it seems like the contentful-export tool is being quite literal while passing the parameter --query-entries insofar as assets are not included on it, and are still retrieved in your response.

I’m going to create an issue on GH so that our engineers can further investigate means to overcome this problem. In the meanwhile, I was able to temporarily work around this issue by passing an empty parameter on --query-assets, such as:

contentful-export --space-id spaceID --management-token Token --query-entries 'sys.id=ValidEntryID' --query-assets 'sys.id=00000'

In your case, you could use a two-step process, getting the ID of the assets that are referenced in the entries, and later querying them with --query-assets 'sys.id[in]=id1,id2,...'

1 Like

Hi Thomas,
Khaled here from the sdk and tools team, Unfortunately that’s currently not possible that’s why we have seperate query-entries and query-assets .
This sounds like a good improvement to add but unfortunately, I can’t give you a timeline on this

Best,
Khaled

Hi guys,

@gabriel: thanks for the workaround. Worked pretty fine for me.

@khaled: Is there a way to skip the asset export completely? The CLI help doesn’t say anything about it.

Thanks and best regards,
Thomas

Hey folks!

To piggyback on this question: Is there any way to β€˜deeply’ export entries?

What I mean by that is, we have entries that contain several layers of linked entries / children, and the export merely exports those children as Links, so that when you import the entries into the new space we get missing or inaccessible entries where the linked entries should be.

(It would be super neat, if there were another argument like --include 3 or something akin to the include argument used for the API’s to resolve linked entries, to have these links resolved for the export.)

Thanks!!

3 Likes

Hi Everyone,

Has anyone come across a solution to last post?

To piggyback on this question: Is there any way to β€˜deeply’ export entries?

This would be incredibly helpful for 2 reasons. I’m working with some very nested referenced components. Maybe 5 or so levels deep and manually writing out the content types to include is a huge pain.

Also I would want just the entries of the content type that are linked to the parent not every instance of the descendant models.

Anyone have any thoughts or experience with this?

5 Likes

@eric.sanchez Did you ever find a solution to this issue?
I have a semi-working solution where I’m fetching each linked entry (using the β€˜include’ parameter) and then exporting them individually, but the issue is unless the most deeply nested links are imported to the new environment first, unresolved link errors will occur. I don’t think fetching linked entries using the include parameter orders them in any particular order.