Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devops: snapshot service #223

Open
2 tasks done
troian opened this issue May 9, 2024 · 4 comments
Open
2 tasks done

devops: snapshot service #223

troian opened this issue May 9, 2024 · 4 comments
Assignees
Labels

Comments

@troian
Copy link
Member

troian commented May 9, 2024

Is your feature request related to a problem? Please describe.

Akash Network needs to have backup source of snapshot which is:

ui

  • authorization by Github org
  • show list of supported networks
    • show list of snapshots
    • schedule snapshot on specific height
  • add new network

snapshots:

  • snapshots for both mainnet and sandbox on following schedule:
    • every hour (keep only latest)
    • every 24h (keep for last 7 days)
    • schedule snapshot at specific height (for example prior network upgrade)

storage
Minio seems to be the best option, but we're open to consider others

Describe the solution you'd like

n/a

Describe alternatives you've considered

n/a

Search

  • I did search for other open and closed issues before opening this

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@Zblocker64
Copy link

I am actively working on this

@Zblocker64
Copy link

Just giving an update on my progress so far...

I have created scripts that prune and create snapshots every hour and uploads them to a minio file server. I have also created scripts that look for an upgrade and will auto create snapshots before and after an upgrade. I am working on creating the production minio server for high availability and fast transfer speed. I am looking to be done mid July with a fully functional snapshot service.

@Zblocker64
Copy link

Here is the main script that makes the snapshot. Still in development and not considered to be final.

# Variables
MINIO_ENDPOINT="http://download.akashprovid.com"
MINIO_ACCESS_KEY="keygohere"
MINIO_SECRET_KEY="secretgohere"
MINIO_BUCKET="akashnet-2"
MINIO_PATH="/"
MINIO_ALIAS="myminio"
CHAIN_ID="akashnet-2"
SNAP_PATH="$HOME/snapshots/akash"
LOG_PATH="$HOME/snapshots/akash/akash_log.txt"
DATA_PATH="$HOME/.akash"
SERVICE_NAME="akash-node"
RPC_ADDRESS="http://localhost:26657"
SNAP_NAME="${CHAIN_ID}_latest.tar.lz4"

# Sets the Minio binary path and renames the previous hours snapshot
export PATH=$PATH:$HOME/minio-binaries/
mc alias set ${MINIO_ALIAS} ${MINIO_ENDPOINT} ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY}
mc mv ${MINIO_ALIAS}/${MINIO_BUCKET}/${SNAP_NAME} ${MINIO_ALIAS}/${MINIO_BUCKET}/${NEW_SNAP_NAME}


log_this() {
    local logging="$@"
    printf "|$(now_date)| $logging\n" | tee -a ${LOG_PATH}
}

# Gets latest block height, not currently using but could use this to name snapshot based off of block height.
LAST_BLOCK_HEIGHT=$(curl -s ${RPC_ADDRESS}/status | jq -r .result.sync_info.latest_block_height)
log_this "LAST_BLOCK_HEIGHT ${LAST_BLOCK_HEIGHT}"

# Stop the Node
log_this "Stopping ${SERVICE_NAME}"
systemctl stop ${SERVICE_NAME}; echo $? >> ${LOG_PATH}

# Compresses the data folder, this is the snapshot file
log_this "Creating new snapshot"
time tar -cf - -C ${DATA_PATH} data 2>>${LOG_PATH} | lz4 -c -9 > ${SNAP_PATH}/${SNAP_NAME} 2>>${LOG_PATH}

# Starts the node
log_this "Starting ${SERVICE_NAME}"
systemctl start ${SERVICE_NAME}; echo $? >> ${LOG_PATH}

# Moves the compressed snapshot location
log_this "Moving new snapshot to ${SNAP_PATH}"
du -hs ${SNAP_PATH} | tee -a ${LOG_PATH}

# Uploads the snapshot to the file server
log_this "Uploading snapshot to Minio"
mc cp ${SNAP_PATH}/${SNAP_NAME} ${MINIO_ALIAS}/${MINIO_BUCKET}/${MINIO_PATH}/ &>>${LOG_PATH}

# Delets the local compressed snapshot
log_this "Removing old snapshot(s):"
cd ${SNAP_PATH}
rm -fv ${SNAP_NAME}

log_this "Done\n---------------------------\n"

@Zblocker64
Copy link

Finalizing the scripts to auto create snapshots at upgrade. Finished the scrips to auto delete snapshots over a week old. The snapshots are fully running and accessible via https://snapshots.akash.network. Docs to come soon. if you want to try it out you can download the latest one at https://snapshots.akash.network/akashnet-2/akashnet-2_latest.tar.lz4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants