Skip to content

Commit 366465c

Browse files
committed
docs: add snapshot doc
1 parent 5ba11a1 commit 366465c

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

docs/snapshots.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Creating and loading warnet snapshots
2+
3+
The `snapshot` command allows users to create snapshots of Bitcoin data directories from active bitcoin nodes. These snapshots can be used for backup purposes, to recreate specific network states, or to quickly initialize new bitcoin nodes with existing data.
4+
5+
## Usage Examples
6+
7+
### Snapshot a Specific bitcoin node
8+
9+
To create a snapshot of a specific bitcoin node:
10+
11+
```bash
12+
warnet snapshot my-node-name -o <snapshots_dir>
13+
```
14+
15+
This will create a snapshot of the bitcoin node named "my-node-name" in the `<snapshots_dir>`. If a directory the directory does not exist, it will be created. If no directory is specified, snapshots will be placed in `./warnet-snapshots` by default.
16+
17+
### Snapshot all nodes
18+
19+
To snapshot all running bitcoin nodes:
20+
21+
```bash
22+
warnet snapshot --all -o `<snapshots_dir>`
23+
```
24+
25+
### Use Filters
26+
27+
In the previous examples, everything in the bitcoin datadir was included in the snapshot, e.g., peers.dat. But there maybe use cases where only certain directories are needed. For example, assuming you only want to save the chain up to that point, you can use the filter argument:
28+
29+
```bash
30+
warnet snapshot my-node-name --filter "chainstate,blocks"
31+
```
32+
33+
This will create a snapshot containing only the 'blocks' and 'chainstate' directories. You would only need to snapshot this for a single node since the rest of the nodes will get this data via IBD when this snapshot is later loaded. A few other useful filters are detailed below:
34+
35+
```bash
36+
# snapshot the logs from all nodes
37+
warnet snapshot --all -f debug.log -o ./node-logs
38+
39+
# snapshot the chainstate and wallet from a mining node
40+
# this is particularly userful for premining a signet chain that
41+
# can be used later for starting a signet network
42+
warnet snapshot mining-node -f "chainstate,blocks,wallets"
43+
44+
# snapshot only the wallets from a node
45+
warnet snapshot my-node -f wallets
46+
47+
# snapshot a specific wallet
48+
warnet snapshot my-node -f mining_wallet
49+
```
50+
51+
## End-to-End Example
52+
53+
Here's a step-by-step guide on how to create a snapshot, upload it, and configure Warnet to use this snapshot when deploying. This particular example is for creating a premined signet chain:
54+
55+
1. Create a snapshot of the mining node:
56+
```bash
57+
warnet snapshot miner --output /tmp/snapshots --filter "blocks,chainstate,wallets"
58+
```
59+
60+
2. The snapshot will be created as a tar.gz file in the specified output directory. The filename will be in the format `{node_name}_{chain}_bitcoin_data.tar.gz`, i.e., `miner_bitcoin_data.tar.gz`.
61+
62+
3. Upload the snapshot to a location accessible by your Kubernetes cluster. This could be a cloud storage service like AWS S3, Google Cloud Storage, or a GitHub repository. If working in a warnet project directory, you can commit your snapshot in a `snapshots/` folder.
63+
64+
4. Note the URL of the uploaded snapshot, e.g., `https://github.com/your-username/your-repo/raw/main/my-warnet-project/snapshots/miner_bitcoin_data.tar.gz`
65+
66+
5. Update your Warnet configuration to use this snapshot. This involves modifying your `network.yaml` configuration file. Here's an example of how to configure the mining node to use the snapshot:
67+
68+
```yaml
69+
nodes:
70+
- name: miner
71+
image:
72+
tag: "27.0"
73+
loadSnapshot:
74+
enabled: true
75+
url: "https://github.com/your-username/your-repo/raw/main/snapshots/miner_bitcoin_data.tar.gz"
76+
# ... other nodes ...
77+
```
78+
79+
6. Deploy Warnet with the updated configuration:
80+
```bash
81+
warnet deploy networks/your_cool_network/network.yaml
82+
```
83+
84+
7. Warnet will now use the uploaded snapshot to initialize the Bitcoin data directory when creating the "miner" node. In this particular example, the blocks will then be distibuted to the other nodes via IBD and the mining node can resume signet mining off the chaintip by loading the wallet from the snapshot:
85+
```bash
86+
warnet bitcoin rpc miner loadwallet mining_wallet
87+
```
88+
89+
## Notes
90+
91+
- Snapshots are specific to the chain (signet, regtest) of the bitcoin node they were created from. Ensure you're using snapshots with the correct network when deploying.
92+
- Large snapshots may take considerable time to upload and download. Consider using filters to reduce snapshot size if you don't need the entire data directory.
93+
- Ensure that your Kubernetes cluster has the necessary permissions to access the location where you've uploaded the snapshot.
94+
- When using GitHub to host snapshots, make sure to use the "raw" URL of the file for direct download.

0 commit comments

Comments
 (0)