Notebook Backups and Exports#
Use backup() to save the native
LabArchives response, or export() to
write a readable directory tree.
Download a Native Backup#
Write LabArchives’ native backup archive to a local file:
notebook.backup("my_notebook.7z")
To leave attachments out of the archive, pass
include_attachments=False:
notebook.backup("metadata_only.7z", include_attachments=False)
Only the notebook owner can request a native backup. Error code 4547 means
you are not authenticated as the owner; check Notebook Settings > Users in
the LabArchives web UI and retry with the owner’s credentials.
Export a Directory Tree#
Export the whole notebook 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 is slow for large
notebooks, because it takes many API requests to list and download pages and
attachments.