# Snapshot

```bash
sudo apt update
sudo apt-get install snapd lz4 -y
```

## Chain Snapshots

Create new file with "sudo nano download\_axone.sh"

```
#!/bin/bash

# Config
BACKUP_URL="https://green.codeblocklabs.com/mainnet/axone/"
TARGET_DIR="$HOME/.axoned"
LOG_FILE="$HOME/axone_backup.log"

# Get today's and yesterday's dates in YYYY-MM-DD format
TODAY=$(date '+%Y-%m-%d')
YESTERDAY=$(date -d 'yesterday' '+%Y-%m-%d')

# Check if backup exists (today or yesterday)
check_backup() {
    local date=$1
    BACKUP_NAME="backup-${date}.tar.lz4"
    
    # Check if file exists on server
    if curl --output /dev/null --silent --head --fail "${BACKUP_URL}${BACKUP_NAME}"; then
        echo "$BACKUP_NAME"
        return 0
    else
        return 1
    fi
}

# Download and extract backup
download_and_extract() {
    local backup_name="$1"
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Found backup: $backup_name" | tee -a "$LOG_FILE"
    
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] ⬇️ Downloading and extracting..." | tee -a "$LOG_FILE"
    mkdir -p "$TARGET_DIR"
    
    # Stream download → lz4 decompress → tar extract
    if curl -sL "${BACKUP_URL}${backup_name}" | lz4 -c -d - | tar -x -C "$TARGET_DIR"; then
        echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Successfully extracted to $TARGET_DIR" | tee -a "$LOG_FILE"
    else
        echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Extraction failed!" | tee -a "$LOG_FILE"
        exit 1
    fi
}

# Main execution
echo "=== Axone Backup Downloader ===" | tee -a "$LOG_FILE"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 🔍 Checking for today's backup ($TODAY)..." | tee -a "$LOG_FILE"

# Try today's backup first
if BACKUP_NAME=$(check_backup "$TODAY"); then
    download_and_extract "$BACKUP_NAME"
else
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] ⏳ Today's backup not found. Checking yesterday ($YESTERDAY)..." | tee -a "$LOG_FILE"
    if BACKUP_NAME=$(check_backup "$YESTERDAY"); then
        download_and_extract "$BACKUP_NAME"
    else
        echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ No backup found for today or yesterday!" | tee -a "$LOG_FILE"
        exit 1
    fi
fi
```

Make it executable

```
chmod +x download_axone_backup.sh
```

Run the download snapshot

```
./download_axone_backup.sh
```

After succesfully download snapshot, run the binary by starting the services

```
// Start the nodes on services
sudo systemctl start axoned.service && sudo journalctl -u axoned.service -f --no-hostname -o cat
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.codeblocklabs.com/blockchain-nodes/axone/snapshot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
