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
- Type and run
dqlite-utils. You will see the repl start. - Type and run the
.snapshotcommand. You will see the ‘snapshot’ shell. - 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. - For each node in the cluster, call
.add-server <address>. - Run the
.infocommand and you will see the servers you’ve just added. Take note of the ID of the server this snapshot will be applied to. - Call
.set-self <id>with the ID from step 5. - If creating a snapshot for a non-fresh cluster, edit raft metadata using the
.set-index,.set-termand.set-timestampcommands. - 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.