From 32c2d42efb0c3760043947ef64340be69f5fd577 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 30 Oct 2020 00:07:02 +0000 Subject: [PATCH] update restore script --- README.md | 6 +++++- restore.sh | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e7e1126e..2a65167d 100644 --- a/README.md +++ b/README.md @@ -119,9 +119,13 @@ Create same linux user account as old server and add to sudoers group and setup Copy backup file to new server -Download and run the restore script, passing it the backup tar file as the first argument +Download the restore script, and edit the postgres username/password at the top of the file. Same instructions as above in the backup steps. ``` wget https://raw.githubusercontent.com/wh1te909/tacticalrmm/develop/restore.sh +``` + +Run the restore script, passing it the backup tar file as the first argument +``` chmod +x restore.sh ./restore.sh rmm-backup-xxxxxxx.tar ``` diff --git a/restore.sh b/restore.sh index 9a8a50d7..a76f7ad1 100755 --- a/restore.sh +++ b/restore.sh @@ -1,6 +1,13 @@ #!/bin/bash -SCRIPT_VERSION="3" +##################################################### + +pgusername="changeme" +pgpw="hunter2" + +##################################################### + +SCRIPT_VERSION="4" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/develop/restore.sh' GREEN='\033[0;32m' @@ -22,6 +29,12 @@ fi rm -f $TMP_FILE +if [[ "$pgusername" == "changeme" || "$pgpw" == "hunter2" ]]; then + printf >&2 "${RED}You must change the postgres username/password at the top of this file.${NC}\n" + printf >&2 "${RED}Check the github readme for where to find them.${NC}\n" + exit 1 +fi + UBU20=$(grep 20.04 "/etc/"*"release") if ! [[ $UBU20 ]]; then echo -ne "\033[0;31mThis restore script will only work on Ubuntu 20.04\e[0m\n" @@ -161,9 +174,6 @@ sleep 2 print_green 'Restoring the database' -pgusername=$(grep -A 6 DATABASES $tmp_dir/rmm/local_settings.py | grep USER | tr -d " \t" | sed 's/.*://' | tr -d "',") -pgpw=$(grep -A 6 DATABASES $tmp_dir/rmm/local_settings.py | grep PASSWORD | tr -d " \t" | sed 's/.*://' | tr -d "',") - sudo -u postgres psql -c "DROP DATABASE IF EXISTS tacticalrmm" sudo -u postgres psql -c "CREATE DATABASE tacticalrmm" sudo -u postgres psql -c "CREATE USER ${pgusername} WITH PASSWORD '${pgpw}'"