Clone Production to Development

From Zenoss Wiki
Revision as of 17:57, 23 October 2012 by Prg3 (Talk | contribs)$7

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Of course you never do Dev work in Production right? Well, here's a script that will clone your dev environment into production 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