How to include attachments in a full XAR export (including children)?

Hi everyone,

we are currently preparing a system migration and trying to clean up our existing XWiki (v10.10) content before moving to a new platform.

Over the years, many attachments (especially images) have been left orphaned because they were deleted in the editor but never removed from the page’s attachments. Our goal is to:

  • Export a complete page/module (with all its children)
  • Include only valid (linked) attachments
  • Exclude unused/orphaned files
  • Get this as a clean .xar file that can be reimported

We’ve tried multiple approaches:

  • Manual .xar export via UI → doesn’t seem to include attachments (at least in v10.10)
  • REST API access → works partially, but doesn’t return child pages reliably or lists empty <pages/>
  • Script-based HTML crawling + attachment download → possible, but not ideal for clean reimport

Main question:
:point_right: Is there a reliable way (via UI, script, extension, or newer version) to export a .xar file that includes all children + their used attachments, without pulling in orphaned files? OR orphaned Files aside, is there a way to export with attachments in older version like ours in the first place?

Any advice from the community would be highly appreciated – especially if there’s an extension or export method we’ve missed.

Thanks in advance! :pray:

Hello , :wave:

Attachments are included in the XAR whether you use the Page export feature or the Admin UI Export feature.

Not that I know of. It’s really hard to define an orphaned attachment. It could be referenced in a script for example.

Yes, the XAR export does that. See https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/Exports#HXARExport for example

Thx

Found this thread from 2019: Finding unused attachments on page (from you hehe :))

hi Vincent,

nice to hear from you again.
yeah this topic haunts me for ages!:wink:

So i have a hard time finding the attachments then.
When i look into a .xar file, the largest files i find are the webhome.xml’s.

Are the attachments bound to those?

Otherwise i dont see any attachments, and there is no “in-/exclude” Option in the xar export as well.

:slight_smile:

Before replying I tested on a local XWiki instance and exported the Sandbox.WebHome page (which has an attachment) and the attachment is there:

  <attachment>
    <filename>XWikiLogo.png</filename>
    <mimetype>image/png</mimetype>
    <author>XWiki.superadmin</author>
    <date>1751287729000</date>
    <version>1.1</version>
    <comment/>
    <content>iVBORw0KGgoAAAANSUhEUgAAAIgAAACFCAYAAACAJLCMAAAFNUlEQVR4Xu2dsY3rRhRF1YDB3AlLUAksYUtg8uFUJTBzaGVOWQJLYAEOWAIBN0D8CsZvARoLCNKDP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gOw2459vGy35atEDz25ywRvlUGspzl1CDOM9sOG7XJWU4uJGdbXuXhwLFUHDd1H3J2EIgIgY+95oWEPrxbhnfA+PB2Kt4ixfvteA/dbvCGTPKXd+zyLlxydoMc5C8vOuR9/OTsbFSC89HIX8FeWkFOao4HhwDHXovyF0kEx16HPR48D+Ts9SjHgxeL4NjrkMeDM+sQ5Gyw4V6nFYCcJX/J2fhFJigbLh75S87KJCk+f1nAkb8kICnPp+jf0++dMRtpZTI+GAYyhv6UozfSA9qC11+s5D8FWEXwqAt9IEnOmgDjE4J0hc6AmCZ+SeAyRpsik7N6QeI/hyJn9YKQv/otAXpByF99zqoFCb45TL8oFWxLlAkS7MvPdYBbiyzb9ILoN6hf30GQRZOzekEC5O8sH4gJdpcJBAm9q7BSCtIIEk0gSOgabIIJ4ucsguyev2fp5HTPnEWQ/fP3HSpm3ivHEGT3/B0CPdb3cxZBvPyNPyybXjknDEGy5O8YazuDbzeC+JJ0cc6G9yWZnvrhVzkQJMutfHz3R/7tA1Fm4+osSBHkuedevbE8KME24CG4hi8FgmyXpbkzCAMEAQQBPV+bpVwGBChXkOEJQS4IUK4gjZEcFqNCgLIlaR05OIrS+A9RR3TQati61AAAAABJRU5ErkJggg==</content>
    <filesize>1390</filesize>
  </attachment>

Just to be clear. The Old Version runs on V10.10. Thats a very old version. Sure exporting attachments was included in that area? Were talking min 5 years ago.

Cheers,
T.

Indeed that’s old (7 years ago :)). What’s sure is that if you use the Admin UI to perform the export (see https://extensions.xwiki.org/xwiki/bin/view/Extension/Administration%20Application#HExport ) you’ll have the attachments in the XAR export.

Ah…we’re onto sth here…that looks drastically different then what i am using. So pls explain to me bcuz i’m dumb. Is that an extra admin extension which i can download or should that be included in the standard 10.10?


thats what i see under export in the administration menu.

and thats what i see when going to the pages export menu
grafik

yes that’s the Admin UI export. If you use that, it’s sure you’ll get the attachments in the XAR since that feature exists since the beginning of XWiki.