Skip to main content

How to create a snapshot

How to create a snapshot

This guide shows you how to create a snapshot of data to be loaded into a new node in a cluster.
This is useful to:

  • bootstrap a new cluster pre-populated with data.
  • (re)introduce a node into the cluster without burdening the leader with excessive data-copying during catch-up.

Steps

  1. Type and run dqlite-utils. You will see the repl start.
  2. Type and run the .snapshot command. You will see the ‘snapshot’ shell.
  3. Include existing data into the snapshot by calling ATTACH DATABASE "/path/to/database.db" AS <name>. Data can be safely modified at this point by running arbitrary SQL commands in this shell.
  4. For each node in the cluster, call .add-server <address>.
  5. Run the .info command and you will see the servers you’ve just added. Take note of the ID of the server this snapshot will be applied to.
  6. Call .set-self <id> with the ID from step 5.
  7. If creating a snapshot for a non-fresh cluster, edit raft metadata using the .set-index, .set-term and .set-timestamp commands.
  8. Call .finish /path/to/snapshot/ with the directory to write the snapshot into.

/path/to/snapshot/ will now contain a snapshot ready to be applied to the node with the ID specified in step 5.

Last updated 10 hours ago. Help improve this document in the forum.