chg: [tools] Updated misp-backup and misp-wipe to be a bit more late 2018 compliant

pull/3766/head
Steve Clement 2018-10-16 13:34:25 +09:00
parent f67d4350de
commit 363d00db7a
4 changed files with 21 additions and 13 deletions

View File

@ -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
```

View File

@ -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}"

View File

@ -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'

View File

@ -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