updated on Wed Jan 11 08:01:35 UTC 2012
[aur-mirror.git] / zoneminder-svn / zmeventbackup
blob71c9538bea418f1651eb053132fbb318eeaf2476
1 #!/bin/bash
2 #===============================================================================
4 # FILE: eventdump.sh
5 #
6 # USAGE: ./eventdump.sh
7 #
8 # DESCRIPTION: Uses mysqldump to create a .sql file for individual zm
9 # events to make Event table recovery possible by doing a
10 # 'find' search in ZoneMinder the events directory
12 # OPTIONS: ---
13 # REQUIREMENTS: --- mysqldump
14 # BUGS: ---
15 # NOTES: ---
16 # AUTHOR: Ross Melin <rdmelin@gmail.com>
17 # COMPANY:
18 # VERSION: 1.0
19 # CREATED: 03/06/2008 11:51:19 AM PST
20 # REVISION: ---
21 #===============================================================================
23 # Edit these to suit your configuration
24 ZM_CONFIG=/etc/zm.conf
25 MYSQLDUMP=/usr/bin/mysqldump
26 EVENTSDIR=/var/lib/zm/www/events
28 # The rest should not need editing
30 # Get the mysql user and password
31 source $ZM_CONFIG
32 MYDUMPOPTS="--user=$ZM_DB_USER --password=$ZM_DB_PASS --skip-opt --compact --quick --no-create-info"
35 for tag in $(find $EVENTSDIR -amin -65 -name ".[0-9]*")
37 EVENT_PATH=$(echo $tag |cut -f 1 -d .)
38 EVENT_ID=$(echo $tag |cut -f 2 -d .)
39 # Dump the sql statements needed to reload the Events, Frames and Stats tables
41 echo "-- ZM_DB_VERSION=$ZM_VERSION
42 " > $EVENT_PATH.sql
44 $MYSQLDUMP $MYDUMPOPTS --where="Id=$EVENT_ID" zm Events >> $EVENT_PATH.sql
45 $MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Frames >> $EVENT_PATH.sql
46 $MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Stats >> $EVENT_PATH.sql
48 done