Exporting and using snapshots

    A snapshot is an exact copy of the Meilisearch database. Snapshots are useful as quick backups, but cannot be used to migrate to a new Meilisearch release.

    This tutorial shows you how to schedule snapshot creation to ensure you always have a recent backup of your instance ready to use. You will also see how to start Meilisearch from this snapshot.

    Meilisearch Cloud and snapshots

    Meilisearch Cloud does not support snapshots.

    Scheduling periodic snapshots

    It is good practice to create regular backups of your Meilisearch data. This ensures that you can recover from critical failures quickly in case your Meilisearch instance becomes compromised.

    Use the --schedule-snapshot configuration option to create snapshots at regular time intervals:

    meilisearch --schedule-snapshot
    

    The first snapshot is created on launch. You will find it in the snapshot directory, /snapshots. Meilisearch will then create a new snapshot every 24 hours until you terminate your instance.

    Meilisearch automatically overwrites old snapshots during snapshot creation. Only the most recent snapshot will be present in the folder at any given time.

    In cases where your database is updated several times a day, it might be better to modify the interval between each new snapshot:

    meilisearch --schedule-snapshot=3600
    

    This instructs Meilisearch to create a new snapshot once every hour.

    TIP

    If you need to generate a single snapshot without relaunching your instance, use the /snapshots route.

    Starting from a snapshot

    To import snapshot data into your instance, launch Meilisearch using --import-snapshot:

    meilisearch --import-snapshot mySnapShots/data.ms.snapshot
    

    Because snapshots are exact copies of your database, starting a Meilisearch instance from a snapshot is much faster than adding documents manually or starting from a dump.

    WARNING

    For security reasons, Meilisearch will never overwrite an existing database. By default, Meilisearch will throw an error when importing a snapshot if there is any data in your instance.

    You can change this behavior by specifying --ignore-snapshot-if-db-exists=true. This will cause Meilisearch to launch with the existing database and ignore the dump without throwing an error.