An AnythingLLM workspace depends on data that lives outside its container image. A backup of the Docker instance's mounted storage and environment file can restore saved workspaces, documents, and settings when the container is replaced.

The storage directory contains the SQLite database, processed documents, and local LanceDB vectors. Stopping AnythingLLM before archiving keeps those files at the same point in time. An external vector database or model server stores its own data separately and needs its own backup. AnythingLLM 1.19.0 has no per-workspace export or import; to move or keep one workspace, this whole-instance backup carries every workspace with its documents, local embeddings, chats, and settings, restored together.

Recovery on the same Linux Docker host can use the existing application image without introducing an upgrade or database migration. Restoring into an empty directory avoids mixing old and new files, while retaining the original directory provides a way back if the restored application fails its checks.

Steps to back up and restore AnythingLLM data:

  1. Set the container name and paths to match your instance and unused backup locations.
    $ export CONTAINER=anythingllm \
      STORAGE_LOCATION="$HOME/anythingllm" \
      BACKUP_ARCHIVE="$HOME/anythingllm-backup.tar.gz" \
      PRE_RESTORE_LOCATION="$HOME/anythingllm-before-restore"

    The commands require Bash on the Linux Docker host, GNU tar, and sudo access to the private storage directory. The archive file and pre-restore directory must not already exist. The variables remain available when backup and recovery use the same shell. Docker access on a standard Linux host is root-equivalent.

  2. Confirm that the container mounts both the storage directory and its environment file.
    $ docker inspect --format '{{range .Mounts}}{{println .Source "->" .Destination}}{{end}}' "$CONTAINER"

    The selected host directory must map to /app/server/storage, and its .env file must map to /app/server/.env. The archive below includes hidden files. If the environment file is elsewhere or exists only inside the container, this directory alone is not a complete backup. The official installation documents the two mounts.
    Related: AnythingLLM Docker storage setup

  3. Retain the current container image identity for recovery.
    $ IMAGE=$(docker inspect --format '{{.Image}}' "$CONTAINER")

    IMAGE holds the installed image's exact local identity. The archive contains application data, not the Docker image or its startup options. For later recovery, the backup needs the original image version and run command or Compose definition alongside it. Restoring with an older or newer version can introduce incompatible database changes.

  4. Check your workspace's saved document list in the Documents panel.

    The upload icon beside a workspace's name opens this panel. The workspace and document names here provide the comparison after recovery; your own names will differ.

  5. Restrict newly created backup files to your account.
    $ umask 077

    The archive includes documents, application keys, and potentially provider credentials from .env. It must stay private; an off-host copy needs protected storage and encrypted transport.

  6. Stop AnythingLLM before copying its data.

    The application will be unavailable until it is started again. An archive taken while it writes the database or vectors can contain inconsistent data.

    $ docker stop "$CONTAINER"
    anythingllm
  7. Archive the complete storage directory into the new backup file.
    $ sudo tar -czf - -C "$STORAGE_LOCATION" . > "$BACKUP_ARCHIVE"

    The shell creates the archive with the private permissions set above, while sudo lets tar read files owned by the container's UID. The trailing dot includes .env, the database, documents, vectors, and other storage contents. Redirection overwrites an existing archive, so the selected filename must be unused.

  8. Verify that the archive can be read through to the end.
    $ tar -tzf "$BACKUP_ARCHIVE"
    ./
    ./push-notifications/
    ./push-notifications/vapid-keys.json
    ##### snipped #####
    ./anythingllm.db
    ##### snipped #####
    ./.env
    ./generated-files/
    ./tmp/
    ./documents/
    ##### snipped #####

    The listing must include .env, anythingllm.db, and the document and vector files used by the instance. A read error or missing data blocks recovery. This is an archive check; the application check after restoration proves that the recovered data is usable. If only a backup is needed now, docker start "$CONTAINER" brings the existing instance back online without performing the restore.

  9. Remove the stopped container before restoring its storage.

    The remaining steps replace the active instance with the backup's state. Changes made after the backup will not appear in that restored state. The original storage directory is retained separately; it must not be deleted before recovery is confirmed.

    $ docker rm "$CONTAINER"
    anythingllm

    Removing this container leaves its bind-mounted host files intact.

  10. Move the original storage directory to the unused recovery location.
    $ sudo mv -T "$STORAGE_LOCATION" "$PRE_RESTORE_LOCATION"

    GNU mv -T treats the destination as the directory's new name rather than placing the source inside an existing directory. The recovery location must be unused.

  11. Create an empty directory at the original storage path.
    $ sudo mkdir -m 700 "$STORAGE_LOCATION"
  12. Extract your backup into the empty storage directory.
    $ sudo tar -xzf "$BACKUP_ARCHIVE" --numeric-owner -C "$STORAGE_LOCATION"

    Extraction as root preserves the saved numeric owners and permissions, including the storage directory itself. The standard AnythingLLM image uses UID/GID 1000:1000. Only a trusted archive from your own instance belongs here; restoring arbitrary archives with sudo can overwrite files or restore unsafe permissions.

  13. Recreate AnythingLLM with the saved image and restored mounts.

    -p 3001:3001 publishes the application on all host interfaces. The host must already block untrusted access, especially if the saved instance has no password protection.

    $ docker run -d \
      --name "$CONTAINER" \
      --cpus 2 --memory 4g \
      -p 3001:3001 \
      -v "$STORAGE_LOCATION:/app/server/storage" \
      -v "$STORAGE_LOCATION/.env:/app/server/.env" \
      -e STORAGE_DIR="/app/server/storage" \
      "$IMAGE"

    This run command fits the standard local-storage instance with a two-CPU and 4 GiB limit. If your instance uses other ports, networks, startup environment variables, or resource settings, its original run command must be reproduced with the restored mounts and saved image. Recreating the container also remounts the restored .env file. No additional Linux capabilities are needed for this backup-and-restore operation.

  14. Confirm that the replacement container is running.
    $ docker ps --filter "name=^/${CONTAINER}$" --format '{{.Image}} {{.State}}'
    daf5a6ae9d36 running

    The image identifier depends on the installed version. A running process alone does not confirm recovery; the browser check follows. Startup errors appear in the application logs.
    Related: How to view Docker logs for AnythingLLM

  15. Verify that the restored workspace contains the same saved documents in its Documents panel.

    The application is available at http://localhost:3001 on the Docker host, or that host's address from another machine. The saved workspace and document list must match the pre-backup view after the page reloads. A welcome screen, missing workspace, or empty document list means recovery has not succeeded. If recovery fails, the original directory in PRE_RESTORE_LOCATION remains available to put back while AnythingLLM is stopped, followed by recreation with the original image and settings. The archive and original directory remain in place after a successful check.

Share this guide