Skip to content

Commit

Permalink
Create snapshot_create.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Sateetje authored Jul 5, 2021
1 parent 260ec44 commit f6c7a71
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions snapshot_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Usage: snapshot_create.sh
# Description: Create and upload snapshot to monitoring server using SSH

# This script using scp, need SSH access to the monitoring server
# ssh-keygen -t rsa
# ssh [email protected] mkdir -p .ssh
# cat /root/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
# ssh [email protected] "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

# VARS:
MONITORINGSERVER="207.180.195.181"
NODEFOLDER="/mnt/proximax/public-mainnet-peer-package-01"
SNAPSHOTFILE="/tmp/snapshot.tar.xz"

[[ ! -d $NODEFOLDER ]] && { echo "The specified path doesn't exists" ; exit 1; }

cd $NODEFOLDER

# Stop container
echo "Stop Docker container"
docker-compose down

# Delete old file if exists
if [[ -f $SNAPSHOTFILE ]]; then
rm -rf $SNAPSHOTFILE
fi

# Create snapshot
echo $(date +%T) "Creating the snapshot, this process can take up more than 1 hour"
tar -cJf $SNAPSHOTFILE ./data

# Start container
echo "Start Docker container"
docker-compose up -d

# Upload to monitoring server
echo $(date +%T) "Uploading the snapshot, this process can take up more than 1 hour"
scp $SNAPSHOTFILE proximax@$MONITORINGSERVER:/tmp

# Delete snapshot
rm -rf $SNAPSHOTFILE

exit 0

0 comments on commit f6c7a71

Please sign in to comment.