Backup Zone Changnes
Posted: Fri Nov 06, 2020 3:05 pm
Since there isn't a undo or history functionality to roll back changes to a zone. I have created a quick solution that uses bash/mysqldump and git to periodically check the zones and if there a changes it gets committed to a local git repo that can then be pushed up to an origin.
This way you can undo changes to zones if you are doing some tweaking or some large scale changes that causes too many triggers or not enough.
How it works
If you ever want to roll it back you can download the the .sql for date and load it back into the database. restart zm to pickup the changes.
This way you can undo changes to zones if you are doing some tweaking or some large scale changes that causes too many triggers or not enough.
Code: Select all
#!/bin/bash
HOST=localhost
DB=zm
USER=zmuser
PASS=zmpass
VERSION=`mysql -u${USER} -p${PASS} -h${HOST} ${DB} < scripts/version.sql | grep -v Value`
mysqldump -u${USER} -p${PASS} -h${HOST} ${DB} Zones | sed 's$VALUES ($VALUES\n($g' | sed 's$),($),\n($g'| grep -v "Dump completed on" > zones/Zones_$VERSION.sql
DATE=`date +"%d-%m-%Y %H:%M"`
MESSAGE="zones updated at ${DATE}"
git add zones/*
git commit -am "$MESSAGE"
git push
- Get version number of the zoneminder database. e.g: 1.35.10
- dump the zones table to folder called zones and name it Zones_1.35.10.sql
- commit the changes to a local git repository
- push the changes up a remote repo
If you ever want to roll it back you can download the the .sql for date and load it back into the database. restart zm to pickup the changes.