Clone Production to Development

From Zenoss Wiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

Of course you never do Dev work in Production right? Well, here's a script that will clone your production environment into development so that you can do dev work against something safer.

#!/bin/bash
 
PRODHOST=zenoss
 
#stop Zenoss
zenoss stop
 
#create a fresh DB backup, and copy it over
ssh zenoss@$PRODHOST zenbackup --no-perfdata --no-eventsdb --file=/tmp/transitionbackup
scp zenoss@$PRODHOST:/tmp/transitionbackup /tmp
ssh zenoss@$PRODHOST rm /tmp/transitionbackup
 
#pull across the directories we want to keep in sync
for i in bin ZenPacks perf Products scripts; do
    rsync -a --delete zenoss@$PRODHOST:$ZENHOME/$i/* $ZENHOME/$i
done
 
# Start the restore into the test system
zenrestore --file=/tmp/transitionbackup
rm /tmp/transitionbackup
 
#Prevent the collectors from starting up on the testing system
touch $ZENHOME/etc/DAEMONS_TXT_ONLY
 
echo "zeneventserver"  >> $ZENHOME/etc/daemons.txt
echo "zopectl"  >> $ZENHOME/etc/daemons.txt
echo "zenhub" >> $ZENHOME/etc/daemons.txt
 
#and now startup Zenoss
zenoss start