How Can I Clone A Chef Server System For Testing Patches or Upgrades?

Sean Horn -

These instructions work for EC 11 HA systems. (And CS12, if you replace private-chef-ctl with chef-server-ctl). There is an example backup made for a standalone CS12 system at the bottom of this document.

You can use that backup to restore a destination Standalone install. You can take the steps given for an HA system and understand that the gist of those steps apply to all installation types. Basically, Primary Backend == Standalone.  A Standalone is really a Primary Backend + single Frontend.

If you are running Chef Server 12, adjust `private-chef-ctl` to read `chef-server-ctl`

The server versions on Source and Destination must be identical.

All commands as root

On the Source HA system

  1. Take a backup of the idle source Primary Backend

    tar -cvpf checkbackup-source.tar /etc/opscode /var/opt/opscode/drbd/data --exclude /etc/opscode/chef-server-running.json --exclude /etc/opscode/private-chef.rb
    
  2. Copy the tar over to the destination Primary Backend

Destination Primary HA Backend System

  1. Install a new Chef Server system with the same version and topology as the source system and reconfigure it into a working state.
  2. Shutdown all services but keepalived on the Primary backend. Also shutdown the keepalived service on the Secondary Backend to avoid failover.

    for i in `private-chef-ctl status | awk '{print $2}' | cut -d ':' -f1,1 | grep -v keepalived`; do private-chef-ctl stop $i; done
    
  3. Make a backup of the current system

    tar -cvpf chefbackup-destination.tar /etc/opscode /var/opt/opscode/drbd/data
    
  4. Delete all the current data

    rm -fr /var/opt/opscode/drbd/data
    
  5. Extract the data from the source server. /etc/opscode/pivotal.pem should match source server,/etc/opscode/private-chef.rb should not.

    tar -xpf chefbackup-source.tar -C /
    
  6. Startup

    private-chef-ctl start
    
  7. Check for any issues in the database startup.

    less /var/log/opscode/postgresql/9.2/current

On the Destination Secondary HA Backend System

  1. Copy the Primary Backend directory `/etc/opscode` here and overwite all current stuff
  2. Startup the keepalived service again

    private-chef-ctl start keepalived

On the Destination Frontends

  1. Copy the Primary Backend directory /etc/opscode here and overwrite all current stuff.
  2. Reconfigure the systems. This should restart services.

    private-chef-ctl reconfigure

 

Standalone and Tiered

If you pay attention to the paths in the backups, /var/opt/opscode/drbd/data vs. /var/opt/opscode/SERVICENAME, it will work for Standalone and Tiered topology installs as well.

You could get a backup of a StandAlone EC system with 

    for i in "`find /var/opt/opscode -name "data" && find /var/opt/opscode/rabbitmq -name "db"`"; do tar -cvpf chefbackup-source.tar $i; done

tar -rpvf chefbackup-source.tar /etc/opscode --exclude /etc/opscode/chef-server-running.json --exclude /etc/opscode/private-chef.rb

bzip2 chefbackup-source.tar

And the same on Chef Server 12 with

    for i in "`find /var/opt/opscode -name "data" && find /var/opt/opscode/rabbitmq -name "db"`"; do tar -cvpf chefbackup-source.tar $i; done

tar -rpvf chefbackup-source.tar /etc/opscode --exclude /etc/opscode/chef-server-running.json --exclude /etc/opscode/chef-server.rb

bzip2 chefbackup-source.tar
Have more questions? Submit a request

Comments

  • Avatar
    Alex Vinyar

    bzip2 is located here - /opt/opscode/embedded/bin/bzip2

  • Avatar
    Irving Popovetsky

    The HA instructions are missing some key steps. I wrote up a more complete version here: https://gist.github.com/irvingpop/22b40ddb6ccf54771dbb

    Can someone integrate, or can we split this out into separate docs?

Powered by Zendesk