Merge pull request #2496 from LeoHChen/node_db_cleanup

[node.sh] enable clean up db/log
pull/2499/head
Leo Chen 5 years ago committed by GitHub
commit 6282639baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      scripts/node.sh

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
version="v1 20200212.0" version="v1 20200313.0"
unset -v progname unset -v progname
progname="${0##*/}" progname="${0##*/}"
@ -97,7 +97,7 @@ print_usage() {
usage: ${progname} [options] usage: ${progname} [options]
options: options:
-c back up database/logs and start clean -c back up database/logs and start clean (not for mainnet)
(use only when directed by Harmony) (use only when directed by Harmony)
-1 do not loop; run once and exit -1 do not loop; run once and exit
-h print this help and exit -h print this help and exit
@ -602,15 +602,19 @@ do
BN_MA="${BN_MA+"${BN_MA},"}${bn}" BN_MA="${BN_MA+"${BN_MA},"}${bn}"
done done
if ${start_clean} if [[ "${start_clean}" == "true" && "${network_type}" != "mainnet" ]]
then then
msg "backing up old database/logs (-c)" msg "cleaning up old database/logs (-c)"
read -rp "Remove old database/logs? (Y/n) " yesno
echo
if [[ "$yesno" == "y" || "$yesno" == "Y" ]]; then
unset -v backup_dir now unset -v backup_dir now
now=$(date -u +%Y-%m-%dT%H:%M:%SZ) now=$(date -u +%Y-%m-%dT%H:%M:%SZ)
mkdir -p backups mkdir -p backups; rm -rf backups/*
backup_dir=$(mktemp -d "backups/${now}.XXXXXX") backup_dir=$(mktemp -d "backups/${now}.XXXXXX")
mv harmony_db_* latest "${backup_dir}/" || : mv -f harmony_db_* latest .dht* "${backup_dir}/" 2>/dev/null || :
rm -rf latest rm -rf latest
fi
fi fi
mkdir -p latest mkdir -p latest

Loading…
Cancel
Save