Notebook Backups and Exports#

Use backup() to save the native LabArchives response, or export() to write a readable directory tree. The examples below assume you already have a notebook object.

Download a Native Backup#

Write LabArchives’ native backup archive to a local file:

notebook.backup("my_notebook.7z")

To omit attachment payloads from the archive, pass include_attachments=False:

notebook.backup("metadata_only.7z", include_attachments=False)

LabArchives only permits the notebook owner’s authenticated account to request a native backup. Error code 4547 means the currently authenticated account is not the owner; check Notebook Settings > Users in the LabArchives web UI and retry with the owner’s credentials.

Export a Directory Tree#

Export the notebook’s top-level directories and pages to a local destination:

export = notebook.export("my_notebook")
destination = export.path

The destination contains numeric ordering prefixes, page content files, and a .labarchives.json manifest for every page. The manifest records the page and entry IDs, output filenames, entry types, and available attachment details. For example:

my_notebook/
└── 1_Experiments/
    └── 1_Run 1/
        ├── 1_text.html
        ├── 2_results.csv
        └── .labarchives.json

Empty directories are created, and empty pages still receive their manifest. If the destination already exists and is not empty, export() raises FileExistsError. Pass overwrite=True to replace it.

Choose an Export Source#

source="auto" is the default. It uses a native backup archive when available and otherwise walks the live API tree. To read native archives, install the export extra:

pip install "labapi[export]"

Use source="backup" to require the native archive, or source="walk" to bypass it and read the live tree directly. A live walk can take a long time for large notebooks: LabArchives requires many API requests to enumerate and download page content and attachment files, so duration grows with notebook size.