head	1.5;
access;
symbols;
locks; strict;
comment	@# @;


1.5
date	2001.07.10.16.36.42;	author stack;	state dead;
branches;
next	1.4;

1.4
date	2001.06.01.16.53.22;	author stack;	state Exp;
branches;
next	1.3;

1.3
date	2001.06.01.00.56.58;	author stack;	state Exp;
branches;
next	1.2;

1.2
date	2001.05.30.00.26.45;	author stack;	state Exp;
branches;
next	1.1;

1.1
date	2001.05.30.00.22.42;	author stack;	state Exp;
branches;
next	;


desc
@@


1.5
log
@Convert '.sh' script to '.pl'.  Add in ability to choose where you want
the database dumped to.
@
text
@#!/bin/sh
##
## Looks in the database pointed to by the sourcecast env.sh 
## file for issues and the tigris database.  Makes a dump of all 
## it finds into a directory named for this script w/ a 
## date suffix in the '/tmp' directory.
##
## Be careful running this script; It will interfere w/ a
## running sites performance.  Use w/ caution.
##
## $Id: dump_tigris_db.sh,v 1.4 2001/06/01 16:53:22 stack Exp $
## 

## Check we've sourced a wholesome env.sh
##
function checkEnv
{
    if [ ! -n "${SANDBOX}" \
            -o ! -d "${SANDBOX}" \
            -o ! -e "${SANDBOX}/scripts/env.sh"  ]
    then
        echo "ERROR: SANDBOX is undefined or is not an extant dir."
        exit 1
    fi

    "${SANDBOX}/scripts/env_check" &> /dev/null
    if [ $? -ne 0 ]
    then
        echo "ERROR: ${SANDBOX}/scripts/env_check failed."
        echo "ERROR: Is env.sh set properly?"
        exit 1
    fi
}


## Script execution starts here.
##

checkEnv

# Create the dir to put dumps into.
#
dir="/tmp/dump_tigris_db.`date '+%Y%m%d%H%M'`"
if [ ! -d $dir ]; then
    mkdir $dir
fi

# Get all issues dbs.
#
issues_dbs=`echo 'show databases like "issues_%"' \
            | mysql -u $DATABASE_ADMIN_USER -p$DATABASE_ADMIN_PASSWORD \
                --host=$DATABASE_HOST --port=$DATABASE_PORT \
            | sed -n "/^issues/p"`


# Cycle over the dbs.
#
echo "Dumping $DATABASE_HOST 'issues_%' and 'tigris' databases to ${dir}"
for db in ${issues_dbs} ${DATABASE_NAME};
do
    echo -n "."
    mysqldump -u ${DATABASE_ADMIN_USER} -p${DATABASE_ADMIN_PASSWORD} \
	--host=${DATABASE_HOST} --port=${DATABASE_PORT} \
	--opt ${db} > ${dir}/${db}.sql
done
echo
@


1.4
log
@+ Added more thorough check that user has sourced env.sh.
+ Added a prompt asking user if they are sure they want to proceed
w/ the loading of a database.
@
text
@d11 1
a11 1
## $Id: dump_tigris_db.sh,v 1.3 2001/06/01 00:56:58 stack Exp $
@


1.3
log
@Check user has sourced and env.sh before running (Previous I had
hard-coded assumption that env.sh to use was at /usr/local/tigris).
@
text
@d11 1
a11 1
## $Id: dump_tigris_db.sh,v 1.2 2001/05/30 00:26:45 stack Exp $
d14 26
a39 7
# Check we've sourced an env.sh
#
if [ ! -n "${SANDBOX}" ]
then
    echo "Source a SANDBOX/scripts/env.sh"
    exit 1
fi
d59 1
a59 1
for db in ${issues_dbs} tigris;
d64 1
a64 1
	--opt --database ${db} > ${dir}/${db}.sql
@


1.2
log
@Just previous, committed w/o comment.  Here is the comment.

Helper scripts for dumping and inserting tigris databases.
See usage and http://helm.tigris.org/migration/ for details on their usage.
@
text
@d11 1
a11 1
## $Id: dump_tigris_db.sh,v 1.1 2001/05/30 00:22:42 stack Exp $
d14 1
a14 1
# Source the sourcecast environment.
d16 5
a20 1
. /usr/local/tigris/scripts/env.sh
@


1.1
log
@*** empty log message ***
@
text
@d9 1
a9 1
## running sites performance.
d11 1
a11 1
## $Id$
@

