Last active
March 23, 2021 09:48
-
-
Save ProBackup-nl/135e4a588be930747e019ce565e6bbdc to your computer and use it in GitHub Desktop.
CrashPlanPROe 3.x for Arch Linux mod
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
#!/bin/bash | |
# nano /opt/proserver/bin/restore_database.sh;chmod 700 /opt/proserver/bin/restore_database.sh | |
################################################################# | |
# Basic setup | |
################################################################# | |
importLog=$PWD/import.log | |
# Find .install.vars and set variables based on their contents | |
INSTALL_VARS_DIR="$(dirname `ls -l $0 | awk '{ print $NF }'`)/.." | |
INSTALL_VARS=$INSTALL_VARS_DIR/.install.vars | |
if [[ -e $INSTALL_VARS ]]; then | |
. $INSTALL_VARS | |
else | |
echo "Install vars not found at $INSTALL_VARS" >> $importLog 2>&1 | |
exit 1 | |
fi | |
BINDIR=$OPTDIR/bin | |
LIBDIR=$OPTDIR/lib | |
CONFDIR=$OPTDIR/conf | |
# Make sure we have exactly one arg | |
if [[ $# -ne 1 ]]; then | |
echo "Usage: $0 /opt/dumps/proserver-db_<id_yyyy-mm-dd_hhmmss>.sql.gz" | |
exit 2 | |
fi | |
# Make sure that the arg is a full path | |
if [[ ! $1 = /* ]]; then | |
echo "Usage: $0 <full path starts with a slash to dump file>" | |
exit 3 | |
fi | |
# Make sure that arg exists as file | |
if [[ ! -f "$1" ]]; then | |
echo "Error: file $1 does not exist." | |
exit 4 | |
fi | |
DUMP_FILE=$1 | |
################################################################# | |
# Shutdown PROe Server | |
################################################################# | |
echo "Shutting down PROe Server..." | |
#$BINDIR/proserver stop >> $importLog 2>&1 | |
systemctl stop crashplan-server >> $importLog 2>&1 | |
# If proserver stop failed to stop the PROe Server process, we | |
# state that and bail out here. | |
if ! (( $? == 0 || $? == 143 )); then | |
echo "Error stopping server process. Exiting upgrade." | |
exit 1 | |
fi | |
################################################################# | |
# Do the heavy lifting | |
################################################################# | |
cd $OPTDIR | |
$JAVACOMMON -cp "$LIBDIR/com.backup42.app.jar:$LIBDIR/h2.jar" -Xms28m -Xmx512m \ | |
com.backup42.RestoreDatabaseFromDump $CONFDIR/conf_proe.groovy $CONFDIR/conf_proe.linux.groovy $CONFDIR/conf_proe.properties $DUMP_FILE $OPTDIR >> $importLog 2>&1 | |
let status=$? | |
cd - | |
if [[ $status -ne 0 ]]; then | |
echo "Restore process was not successful, exit=$status, will not restart PROe Server" >> $importLog 2>&1 | |
echo "Restore process was not successful, exit=$status, will not restart PROe Server. View $importLog for details." | |
exit 1 | |
fi | |
# Secure the database files | |
chmod 600 "$OPTDIR/db/proserver.h2.db" | |
chmod 600 "$OPTDIR/db.bak/proserver.h2.db" | |
################################################################# | |
# Start PROe Server | |
################################################################# | |
echo "Starting PROe Server..." | |
#$BINDIR/proserver start >> $importLog 2>&1 | |
# start using systemd unit | |
systemctl start crashplan-server >> $importLog 2>&1 | |
# and we're done | |
echo "" >> $importLog 2>&1 | |
echo "Import complete: " >> $importLog 2>&1 | |
echo " `ps aux | grep 'app=PROServer' | grep -v grep`" >> $importLog 2>&1 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original script improved with help text, input checks, logging at 1 location (line #62
cd $OPTDIR
caused partial logging there), and systemd units.