2008-02-14 06:33:01 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#===============================================================================
|
|
|
|
#
|
|
|
|
# FILE: zmeventdump
|
|
|
|
#
|
2008-03-10 17:38:59 +08:00
|
|
|
# USAGE: ./zmeventdump <FullPathToEventDirectory>
|
2008-02-14 06:33:01 +08:00
|
|
|
#
|
|
|
|
# DESCRIPTION: Uses mysqldump to create a .sql file for individual zm
|
|
|
|
# events to make Event table recovery possible by doing a
|
|
|
|
# 'find' search in ZoneMinder the events directory
|
|
|
|
#
|
|
|
|
# OPTIONS: --- None
|
|
|
|
# REQUIREMENTS: --- mysqldump
|
|
|
|
# BUGS: ---
|
|
|
|
# NOTES: ---
|
2008-03-10 17:38:59 +08:00
|
|
|
# AUTHOR: Ross Melin <rdmelin>
|
2008-02-14 06:33:01 +08:00
|
|
|
# COMPANY:
|
2008-03-10 17:38:59 +08:00
|
|
|
# VERSION: 3.0
|
|
|
|
# CREATED: 02/27/2008 05:39:00 PM PST
|
|
|
|
# REVISION: --- Update for changed zmfilter and
|
|
|
|
# ZM_USE_DEEP_STORAGE
|
2008-02-14 06:33:01 +08:00
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
# Edit these to suit your configuration
|
|
|
|
ZM_CONFIG=@ZM_CONFIG@
|
2013-11-01 21:47:28 +08:00
|
|
|
# ZM_VERSION in the config is now deprecated but will likely still exist in people's config files. This will override it.
|
|
|
|
ZM_VERSION=@VERSION@
|
2008-02-14 06:33:01 +08:00
|
|
|
MYSQLDUMP=/usr/bin/mysqldump
|
2008-03-10 17:38:59 +08:00
|
|
|
|
2008-02-14 06:33:01 +08:00
|
|
|
# The rest should not need editing
|
|
|
|
|
|
|
|
# Get the mysql user and password
|
|
|
|
source $ZM_CONFIG
|
|
|
|
|
2008-03-10 17:38:59 +08:00
|
|
|
# zmfilter now passes the full path as an argument
|
2008-02-14 06:33:01 +08:00
|
|
|
EVENT_PATH=$1
|
|
|
|
|
2008-03-10 17:38:59 +08:00
|
|
|
# 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"
|
2008-02-14 06:33:01 +08:00
|
|
|
|
|
|
|
# Dump the sql statements needed to reload the Events, Frames and Stats tables
|
|
|
|
|
2008-09-30 16:41:23 +08:00
|
|
|
echo "-- ZM_DB_VERSION=$ZM_VERSION
|
2008-03-10 17:38:59 +08:00
|
|
|
" > $EVENT_PATH/.sql
|
2008-02-14 06:33:01 +08:00
|
|
|
|
2008-03-10 17:38:59 +08:00
|
|
|
$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
|
2008-02-14 06:33:01 +08:00
|
|
|
|
|
|
|
exit 0
|