33Backup / Restore Format
44=======================
55
6- The ``backup_restore `` applet lets you export a learning package (V2 content
6+ The ``backup_restore `` applet lets you back up a learning package (V2 content
77library) to a portable ZIP archive and restore it on the same or a different
88Open edX instance.
99
@@ -14,13 +14,21 @@ Open edX instance.
1414Overview
1515--------
1616
17+ .. note ::
18+
19+ A **Library ** (the user-facing V2 content library) has exactly one
20+ **Learning Package ** where it stores its content, but Learning Packages can
21+ also exist independently. During a restore, the system first creates a
22+ standalone Learning Package for inspection; once the operator confirms the
23+ content, that Learning Package is associated with a newly created Library.
24+
1725A backup ZIP is a self-contained snapshot of one learning package. It captures
18- every component, collection, container (sections / subsections / units ), and
26+ every component, collection, container (section / subsection / unit ), and
1927static asset. For each component and container, only the current draft and
2028published versions are exported — the full version history is not preserved.
2129
2230The archive uses `TOML <https://toml.io >`_ for all metadata files and keeps the
23- actual XBlock content as XML (the same `` block.xml `` format Studio has always
31+ actual component XBlock content as XML (the same OLX format Studio has always
2432used). This makes backups both machine-readable and human-inspectable.
2533
2634.. note ::
@@ -63,6 +71,15 @@ Python API::
6371 if result["status"] == "error":
6472 print(result["log_file_error"].getvalue())
6573
74+ .. warning ::
75+
76+ Do **not ** rely on the ``key `` stored in ``package.toml `` to determine
77+ where the content is restored. Always pass ``package_ref `` explicitly to
78+ ``load_learning_package ``; trusting the archive's own key is a security
79+ risk and can lead to content being restored under an unintended identifier.
80+ Similarly, never pass ``user `` from the archive — always supply the
81+ authenticated operator making the restore request.
82+
6683.. note ::
6784
6885 ``load_learning_package `` accepts an optional ``package_ref `` argument.
@@ -240,6 +257,11 @@ Example::
240257Container entity TOML (``entities/<slug>.toml ``)
241258~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
242259
260+ The ``<slug> `` is derived from the last segment of the container's
261+ ``entity_ref ``. If two containers share the same last segment (e.g. a Unit
262+ and a Subsection both named "intro"), a short hash is appended to the
263+ second to avoid filename collisions (e.g. ``intro-48afa3.toml ``).
264+
243265Sections, subsections, and units share the same base structure with an
244266additional ``[entity.container.<type>] `` marker (``section ``, ``subsection ``,
245267or ``unit ``) and a ``[version.container] `` table that lists child keys.
@@ -309,9 +331,24 @@ Example::
309331XBlock content (``component_versions/v<N>/block.xml ``)
310332~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311333
312- Standard XBlock XML, identical to what Studio stores internally. Static assets
313- (images, PDFs, etc.) referenced with ``/static/<filename> `` in the XML are
314- stored alongside the XML under ``component_versions/v<N>/static/ ``.
334+ OLX (Open Learning XML) for the component, in the same format Studio uses
335+ internally. Static assets (images, PDFs, etc.) referenced with
336+ ``/static/<filename> `` in the XML are stored alongside under
337+ ``component_versions/v<N>/static/ ``.
338+
339+ .. note ::
340+
341+ Unlike the old modulestore OLX export — where each component's file was
342+ named after its ``block_id `` (often a machine-generated UUID) — this format
343+ always names the file ``block.xml ``. The component's identifier lives in
344+ the parent TOML file, not the filename.
345+
346+ .. note ::
347+
348+ **HTMLBlock limitation: ** HTML content is currently serialized inline using
349+ a CDATA section rather than stored in a separate ``.html `` file. This
350+ differs from old course OLX exports and is a known limitation of the current
351+ XBlock serialization layer.
315352
316353Example ``block.xml ``::
317354
0 commit comments