|
| 1 | +Backing up and sharing projects |
| 2 | +=============================== |
| 3 | + |
| 4 | +Two CLI commands help you move a project between machines or archive it for long-term storage: |
| 5 | + |
| 6 | +* ``cheese3d checkpoint``: bundles a project into a single archive |
| 7 | +* ``cheese3d restore``: expands an archive back into a working project |
| 8 | + |
| 9 | +This guide explains: |
| 10 | + |
| 11 | +.. contents:: |
| 12 | + :local: |
| 13 | + :depth: 1 |
| 14 | + :backlinks: none |
| 15 | + |
| 16 | +What is a checkpoint? |
| 17 | +--------------------- |
| 18 | + |
| 19 | +A **checkpoint** is a single ``.tar.xz`` archive that captures the state of a Cheese3D project at a point in time. Archives are written to the project's ``checkpoints/`` folder using the naming scheme: |
| 20 | + |
| 21 | +.. code-block:: text |
| 22 | +
|
| 23 | + <project>/checkpoints/<name>_<YYYY-MM-DD-HH-MM-SS>.tar.xz |
| 24 | +
|
| 25 | +The timestamp is generated when the command is run, so successive checkpoints never overwrite each other. |
| 26 | + |
| 27 | +Checkpoints are useful for: |
| 28 | + |
| 29 | +* **Snapshotting before a destructive change.** Take a checkpoint before retraining the pose model, re-running synchronization, or editing labels. If the new run is worse, ``restore`` brings you back to the previous state. |
| 30 | +* **Sharing a project.** Hand a single ``.tar.xz`` to a collaborator or upload it to long-term storage instead of dealing with many loose files and possibly external symlinks. |
| 31 | +* **Moving a project between machines.** Use ``--portable`` (see :ref:`howto/backups:Portable archives` below) to ensure the archive is self-contained regardless of where its data originally lived. |
| 32 | + |
| 33 | +What is included in a checkpoint |
| 34 | +-------------------------------- |
| 35 | + |
| 36 | +By default, ``cheese3d checkpoint`` includes everything inside the project folder *except* the ``checkpoints/`` subfolder itself. Concretely, that means: |
| 37 | + |
| 38 | +* ``config.yaml``: always included (and possibly rewritten; see :ref:`howto/backups:Portable archives` below) |
| 39 | +* ``triangulation/``: always included |
| 40 | +* ``model/`` (the default ``model_root``): included *if* the model lives inside the project folder; externalized model directories are only included when ``--portable`` is set |
| 41 | +* ``videos/`` (the default ``video_root``): included *if* the videos live inside the project folder and ``--skip-source`` is *not* set; externalized video roots require ``--portable`` |
| 42 | +* ``ephys/`` (the default ``ephys_root``): same rules as ``videos/``---included by default when ``ephys_root`` is inside the project folder, requires ``--portable`` otherwise |
| 43 | + |
| 44 | +See :doc:`/guides/organizing-projects` for the project layout these ``*_root`` folders refer to. |
| 45 | + |
| 46 | +.. tip:: |
| 47 | + |
| 48 | + Because source recordings (videos and ephys) are typically large, you can opt out of them at archive time with ``--skip-source``; the resulting archive contains the configuration, the trained model, the triangulation outputs, and any other project files, but not the raw inputs. |
| 49 | + |
| 50 | +Creating a checkpoint |
| 51 | +--------------------- |
| 52 | + |
| 53 | +The minimal invocation, from inside a project folder: |
| 54 | + |
| 55 | +.. code-block:: bash |
| 56 | +
|
| 57 | + cheese3d checkpoint |
| 58 | +
|
| 59 | +To explicitly skip source recordings (useful when you only want to share the *results* of an analysis): |
| 60 | + |
| 61 | +.. code-block:: bash |
| 62 | +
|
| 63 | + cheese3d checkpoint --skip-source |
| 64 | +
|
| 65 | +See :ref:`reference/cli:checkpoint` for the full set of options. |
| 66 | + |
| 67 | +Portable archives |
| 68 | +^^^^^^^^^^^^^^^^^ |
| 69 | + |
| 70 | +The defaults above only bundle source recordings and models that live **inside the project folder**. If your ``video_root``, ``ephys_root``, or ``model_root`` points to a shared location (e.g., a lab-wide ``dlc-projects/`` folder or an external drive), those files won't appear in a default archive---the resulting checkpoint won't be self-contained for transfer to another machine. |
| 71 | + |
| 72 | +The ``--portable`` flag fixes this: |
| 73 | + |
| 74 | +.. code-block:: bash |
| 75 | +
|
| 76 | + cheese3d checkpoint --portable |
| 77 | +
|
| 78 | +With ``--portable``: |
| 79 | + |
| 80 | +* External directories pointed to by ``video_root``, ``ephys_root``, and ``model_root`` are copied into the archive under standard subfolders (``videos/``, ``ephys/``, and ``models/``). |
| 81 | +* Symbolic links inside source folders are resolved and the linked files are copied in directly. |
| 82 | +* The embedded ``config.yaml`` is rewritten so ``video_root``, ``ephys_root``, and ``model_root`` are set to those standard subfolders. So on restore, the project simply works without further reconfiguration. |
| 83 | + |
| 84 | +``--portable`` and ``--skip-source`` are independent. Combining them produces a self-contained archive of *just* the model and analysis outputs without raw recordings: |
| 85 | + |
| 86 | +.. code-block:: bash |
| 87 | +
|
| 88 | + cheese3d checkpoint --portable --skip-source |
| 89 | +
|
| 90 | +.. tip:: |
| 91 | + |
| 92 | + If you're handing a project off to someone who doesn't share your filesystem layout, always use ``--portable``. The archive is then guaranteed to restore into a working project on any machine. |
| 93 | + |
| 94 | +Restoring a checkpoint |
| 95 | +---------------------- |
| 96 | + |
| 97 | +``cheese3d restore`` expands an archive back into a project on disk: |
| 98 | + |
| 99 | +.. code-block:: bash |
| 100 | +
|
| 101 | + cheese3d restore path/to/<name>_<timestamp>.tar.xz |
| 102 | +
|
| 103 | +By default, the project is restored under the ``--path`` directory using the project name baked into the archive. To restore under a different name, pass it as the second argument: |
| 104 | + |
| 105 | +.. code-block:: bash |
| 106 | +
|
| 107 | + cheese3d restore my_project_2026-05-13-09-30-00.tar.xz my_project_copy |
| 108 | +
|
| 109 | +You can also skip source recordings at restore time. This is useful when you have a large portable archive but only need the configuration, model, and analysis results on the target machine: |
| 110 | + |
| 111 | +.. code-block:: bash |
| 112 | +
|
| 113 | + cheese3d restore my_project.tar.xz --skip-source |
| 114 | +
|
| 115 | +See :ref:`reference/cli:restore` for the full set of options. |
| 116 | + |
| 117 | +.. note:: |
| 118 | + |
| 119 | + ``restore`` will not delete files that already exist in the target directory; it only extracts files from the archive on top of what's already there. To guarantee a clean restore, point ``--path`` at an empty folder, or remove the target project directory before running ``restore``. |
0 commit comments