# Snapshot & State sync

## Snapshot

```bash
sudo systemctl stop atomoned

cp $HOME/.atomone/data/priv_validator_state.json $HOME/.atomone/priv_validator_state.json.backup
atomoned tendermint unsafe-reset-all --home ~/.atomone/ --keep-addr-book

curl https://ss.syanodes.my.id/atomone/ss-atomone.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.atomone

mv $HOME/.atomone/priv_validator_state.json.backup $HOME/.atomone/data/priv_validator_state.json

sudo systemctl restart atomoned && sudo journalctl -fu atomoned -o cat
```

## State Sync

```bash
sudo systemctl stop atomoned

cp $HOME/.atomone/data/priv_validator_state.json $HOME/.atomone/priv_validator_state.json.backup
atomoned tendermint unsafe-reset-all --home $HOME/.atomone

peers="883d672fad793dd87764cd578aa07f390ab500e3@169.155.46.203:26656,622c89060ed88ac4c9d29f0e18ad8fb72fa07104@159.65.101.79:26656,302b2277a5936c5cf9225fa54b6b627df960b43c@212.56.47.197:26656,ca6b5e45924deaba86616d1d7dad29182d83aa0f@5.78.119.101:26656,66dd543dac0f7fdf865190dc904bc46caedcdd07@2001:bc8:702:16d0::5:26656,51ebff95bd1ecfde3eff1dc8b16b5c497d87b0b5@88.99.252.213:26656,af89f2273ff313b143d49376eca165ecd9673393@5.9.94.151:26706,2c02f0e92e00a7fdacdfafb1919b3424047b1701@45.87.107.24:27656,752bb5f1c914c5294e0844ddc908548115c1052c@65.108.236.5:14556,dc92e7b8ed2aafc34c400405916569aad0d990f3@169.155.44.68:26656,706a835221dcc171afa14429fac536d6b5a3736d@63.250.54.71:26656,af9595a740be37ddf8aac7eedc4699786f2e98a9@65.109.78.7:29956,ca1d8ab2fdc1cbff4c8283ddbcc8fd53a7d9a254@65.21.215.167:26656,522826623d65d27ef3f7db8a5259d003be5a93d3@65.108.229.19:26666,1edb42a4ee4526f80882ef6821b0bb231d320447@135.181.61.200:27656,9e6916423eaa4302127a0b7cb518ead4f8b98fd8@89.109.112.42:30656,b1cd93aaa6ce46e536893c3d0ae064134e70849f@65.21.79.120:26656,61b7861a468dfa84532526afd98bea81bf41a874@121.78.247.244:16656,d3adcf9eee8665ee2d3108f721b3613cdd18c3a3@23.227.223.49:26656,6219193bd3b127e980686b745b97bdcd2ff429ef@95.217.107.137:11656,e28ee47043a193f67fa9598a47a32494c5382a12@164.92.105.245:26656,9aceed722f09a3b0de202bbdd98dc345e2b84731@65.108.109.48:26656,e1b058e5cfa2b836ddaa496b10911da62dcf182e@164.152.161.227:26656,a05191b9ec3023be00e9584d5255f7dfcd3a167e@135.181.138.95:2110,da165aaeac3adbc9845879e06f336c2668c5d915@65.21.214.84:9756,a9d606f503566650d39e8c7e381c78918218f0fe@95.217.204.58:29956"
SNAP_RPC="https://atomone-m-rpc.syanodes.my.id:443"

sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" $HOME/.atomone/config/config.toml 

LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height);
BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000));
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) 

echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH && sleep 2

sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ;
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ;
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ;
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ;
s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $HOME/.atomone/config/config.toml

mv $HOME/.atomone/priv_validator_state.json.backup $HOME/.atomone/data/priv_validator_state.json

sudo systemctl restart atomoned && sudo journalctl -fu atomoned -o cat
```
