-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |