Bug 461 - Updated Ross script

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2342 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2008-03-10 09:38:59 +00:00
parent 5335397f58
commit 3f2a6bff1b
1 changed files with 16 additions and 12 deletions

View File

@ -3,7 +3,7 @@
#
# FILE: zmeventdump
#
# USAGE: ./zmeventdump <MonitorName>/<EventId>
# USAGE: ./zmeventdump <FullPathToEventDirectory>
#
# DESCRIPTION: Uses mysqldump to create a .sql file for individual zm
# events to make Event table recovery possible by doing a
@ -13,34 +13,38 @@
# REQUIREMENTS: --- mysqldump
# BUGS: ---
# NOTES: ---
# AUTHOR: Ross Melin <rdmelin@yahoo.com>
# AUTHOR: Ross Melin <rdmelin>
# COMPANY:
# VERSION: 2.0
# CREATED: 05/26/2006 06:21:00 AM PDT
# REVISION: ---
# VERSION: 3.0
# CREATED: 02/27/2008 05:39:00 PM PST
# REVISION: --- Update for changed zmfilter and
# ZM_USE_DEEP_STORAGE
#===============================================================================
# Edit these to suit your configuration
ZM_CONFIG=@ZM_CONFIG@
EVENTS_DIR=events
MYSQLDUMP=/usr/bin/mysqldump
# The rest should not need editing
# Get the mysql user and password
source $ZM_CONFIG
# zmfilter now passes the full path as an argument
EVENT_PATH=$1
EVENT_ID=$(echo $1 |cut -f 2 -d / )
MYDUMPOPTS="--user=$ZM_DB_USER --password=$ZM_DB_PASS --skip-opt --compact --quick --no-create-info"
# Get the event id from a filename in the event directory
EVENT_ID=$(ls $1/.[0-9]* | sed s:$1\/\.::)
MYDUMPOPTS="--user=$ZM_DB_USER --password=$ZM_DB_PASS --skip-opt --compact --quick --no-create-info"
# Dump the sql statements needed to reload the Events, Frames and Stats tables
echo "--- ZM_DB_VERSION=$ZM_VERSION
" > $ZM_PATH_WEB/$EVENTS_DIR/$EVENT_PATH/.sql
" > $EVENT_PATH/.sql
$MYSQLDUMP $MYDUMPOPTS --where="Id=$EVENT_ID" zm Events >> $ZM_PATH_WEB/$EVENTS_DIR/$EVENT_PATH/.sql
$MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Frames >> $ZM_PATH_WEB/$EVENTS_DIR/$EVENT_PATH/.sql
$MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Stats >> $ZM_PATH_WEB/$EVENTS_DIR/$EVENT_PATH/.sql
$MYSQLDUMP $MYDUMPOPTS --where="Id=$EVENT_ID" zm Events >> $EVENT_PATH/.sql
$MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Frames >> $EVENT_PATH/.sql
$MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Stats >> $EVENT_PATH/.sql
exit 0