opensim script improvements
[feisty_meow.git] / scripts / opensim / backup_opensim.sh
index 8619ae47a1a8d6960819b60a85c93d974e0b2cd1..508cad3fae82f3c41c4354fec46c0440f118f761 100644 (file)
@@ -1,18 +1,22 @@
 #!/bin/bash
 # a simple script that backs up the opensim database assets.
 
-#hmmm: need to parameterize for the database name and secrets file and all that.
-#      would be nice to have a block of opensim variables, perhaps an associative
-#      array of config chunks.
+gridusername="$1"; shift
+databasename="$1"; shift
 
-source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
+if [ -z "$gridusername" -o -z "$databasename" ]; then
+  echo "
+This script takes two parameters: (1) the user name for the opensim database
+and (2) the database name.  It will backup that database by logging into
+mysql as the user.  The user's password for mysql must be recorded in a local
+file called: \$HOME/.secrets/opensim_db_password.txt"
+fi
+
+source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
 
 host=$(echo $(hostname) | sed -e 's/\([^.]*\)\..*/\1/')
 
 bkupname="backup-opensim_${host}_$(date_stringer).mysql_bkup"
-mysqldump -u griduser -p$(cat $HOME/.secrets/opensim_db_password.txt) opensim > "$bkupname"
-# note that the above assumes the database is called "opensim".  it might be
-# called opengrid instead, based on the setup procedure that was followed.
-# likewise the user might be someone other than "griduser".
+mysqldump -u "$gridusername" -p$(cat $HOME/.secrets/opensim_db_password.txt) "$databasename" > "$bkupname"
 gzip "$bkupname"