---
title: How to create a snapshot
description: Canonical makes open source secure, reliable and easy to use, providing
  support for Ubuntu and a portfolio of enterprise-grade technologies. Founded in
  2004, Canonical operates globally with team members in over 80 countries.
url: https://canonical.com/dqlite/docs/howto/create-a-snapshot?format=md
---

*Submit*

# 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](https://canonical.com/dqlite/docs/howto/create-a-snapshot?format=md#p-625-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.

---

[Previous

Check data-integrity](https://canonical.com/dqlite/docs/howto/check-data-integrity)
[Next

Inspect raft node status](https://canonical.com/dqlite/docs/howto/inspect-raft-node-status)

Last updated 2 months ago. [Help improve this document in the forum](https://discourse.dqlite.io/t/how-to-create-a-snapshot/558).
