diff --git a/tools/misp-backup/README.md b/tools/misp-backup/README.md index c9b1e67cf..6dc3246f9 100644 --- a/tools/misp-backup/README.md +++ b/tools/misp-backup/README.md @@ -18,7 +18,7 @@ Running run the script: ```` -sh misp-backup.sh +sudo sh misp-backup.sh ```` Open @@ -65,6 +65,8 @@ Description Run the script ============== +/!\ This has not been tested on the latest MISP version (2.4.96) - Thread carefully and pack your Banana picker(tm). + ``` -run ./misp-restore.sh PATH_TO_ARCHIVE.tar.gz +sudo sh ./misp-restore.sh PATH_TO_ARCHIVE.tar.gz ``` diff --git a/tools/misp-backup/misp-backup.sh b/tools/misp-backup/misp-backup.sh index 81e8c32d1..bfa20b7a9 100755 --- a/tools/misp-backup/misp-backup.sh +++ b/tools/misp-backup/misp-backup.sh @@ -16,7 +16,7 @@ ## built system. This is not intended as an upgrade script ## to move between MISP versions - But it might work ;). ## -## Tested against MISP 2.4.33 +## Tested against MISP 2.4.96 ## ## Run the script as the standard user with the command below ## @@ -58,6 +58,7 @@ MISPPath=${MISPPath:-$(locate MISP/app/webroot/index.php|sed 's/\/app\/webroot\/ # Output OutputFileName=${OutputFileName:-MISP-Backup} OutputDirName=${OutputDirName:-/tmp} +OutputFull="${OutputDirName}/${OutputFileName}-$(date '+%Y%m%d_%H%M%S').tar.gz" # database.php MySQLUUser=$(grep -o -P "(?<='login' => ').*(?=')" $MISPPath/app/Config/database.php) MySQLUPass=$(grep -o -P "(?<='password' => ').*(?=')" $MISPPath/app/Config/database.php) @@ -75,7 +76,7 @@ GnuPGHomeDir=$(grep -o -P "(?<='homedir' => ').*(?=')" $MISPPath/app/Config/conf GnuPGPass=$(grep -o -P "(?<='password' => ').*(?=')" $MISPPath/app/Config/config.php) # Create backup files TmpDir="$(mktemp --tmpdir=$OutputDirName -d)" -cp $GnuPGHomeDir/* $TmpDir/ +cp -r $GnuPGHomeDir/* $TmpDir/ echo "copy of org images and other custom images" cp -r $MISPPath/app/webroot/img/orgs $TmpDir/ cp -r $MISPPath/app/webroot/img/custom $TmpDir/ @@ -93,7 +94,9 @@ MySQLRPass=${MySQLRPass:-$MySQLUPass} mysqldump --opt -u $MySQLRUser -p$MySQLRPass $MISPDB > $TmpDir/MISPbackupfile.sql # Create compressed archive cd $TmpDir -tar -zcf $OutputDirName/$OutputFileName-$(date "+%Y%m%d_%H%M%S").tar.gz * +tar -zcf $OutputFull * cd - rm -rf $TmpDir -echo 'MISP Backup Complete!!!' +echo "MISP Backup Completed, OutputDir: ${OutputDirName}" +echo "FileName: ${OutputFileName}-$(date '+%Y%m%d_%H%M%S').tar.gz" +echo "FullName: ${OutputFull}" diff --git a/tools/misp-backup/misp-restore.sh b/tools/misp-backup/misp-restore.sh index 50b92151d..ba51552cc 100644 --- a/tools/misp-backup/misp-restore.sh +++ b/tools/misp-backup/misp-restore.sh @@ -20,7 +20,7 @@ # - SSL certificates used by the web server # # -# run ./misp-restore.sh PATH_TO_ARCHIVE.tar.gz +# sudo sh ./misp-restore.sh PATH_TO_ARCHIVE.tar.gz # echo '-- Starting MISP restore process' diff --git a/tools/misp-wipe/misp-wipe.sh b/tools/misp-wipe/misp-wipe.sh index b7f07c486..951fb487b 100755 --- a/tools/misp-wipe/misp-wipe.sh +++ b/tools/misp-wipe/misp-wipe.sh @@ -1,5 +1,5 @@ #@IgnoreInspection BashAddShebang -#!/bin/sh +#!/bin/bash ## ## script to wipe MISP on debian/ubuntu ## @@ -11,21 +11,24 @@ ## ## This script can be used to reset a MISP instance ## by clearing all events, orgs and users. -## It is highy recommended ## to run misp-backup.sh first! +## It is highy recommended to run misp-backup.sh first! ## -## Tested against MISP 2.4.55 +## Tested against MISP 2.4.96 ## ## Run the script as the standard user with the command below ## ## cp misp-wipe.conf.sample misp-wipe.conf ## vi misp-wipe.conf # adjust values -## sudo sh -x misp-wipe.sh 2>&1 | tee misp-wipe.log +## sudo bash -x misp-wipe.sh 2>&1 | tee misp-wipe.log +## +## /!\ This might fail or create a random '0' file if using ZSH... (Oh-My...Berk) ## ## Time to set some variables ## -if (( $EUID > 0 )) - then +LUSER_ID="$(id -u)" + +if [[ "${LUSER_ID}" > "0" ]]; then echo "Please run this as a privileged user" echo "(usually 'sudo !!' will cover you)" exit