Merge branch 'master' of feistymeow.org:feisty_meow
[feisty_meow.git] / scripts / opensim / backup_opensim.sh
1 #!/bin/bash
2 # a simple script that backs up the opensim database assets.
3
4 gridusername="$1"; shift
5 databasename="$1"; shift
6
7 if [ -z "$gridusername" -o -z "$databasename" ]; then
8   echo "
9 This script takes two parameters: (1) the user name for the opensim database
10 and (2) the database name.  It will backup that database by logging into
11 mysql as the user.  The user's password for mysql must be recorded in a local
12 file called: \$HOME/.secrets/opensim_db_password.txt"
13 fi
14
15 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
16
17 host=$(echo $(hostname) | sed -e 's/\([^.]*\)\..*/\1/')
18
19 bkupname="backup-opensim_${host}_$(date_stringer).mysql_bkup"
20 mysqldump -u "$gridusername" -p$(cat $HOME/.secrets/opensim_db_password.txt) "$databasename" > "$bkupname"
21 gzip "$bkupname"
22