Skip to content

Instantly share code, notes, and snippets.

@jeremymv2
Last active April 2, 2020 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jeremymv2/9c14086e13cac572235fe4bab5881ed3 to your computer and use it in GitHub Desktop.
Save jeremymv2/9c14086e13cac572235fe4bab5881ed3 to your computer and use it in GitHub Desktop.
knife-ec-backup examples
#!/bin/bash
set -e
# Customize all these values
# youre source/destination keys and
# configs will differ
BACKUPDIR="backups"
BACKUPLOG="./migration_backup.log"
RESTORELOG="./migration_restore.log"
SRCWEBUIKEY="conf/src_webui_priv.pem"
DSTWEBUIKEY="conf/dst_webui_priv.pem"
SRCKNIFERB="conf/src_knife.rb"
DSTKNIFERB="conf/dst_knife.rb"
BACKUPCONCURRENCY=50
function runbackup () {
echo "-- BACKUP STARTING --" >> ${BACKUPLOG}
knife ec backup ${BACKUPDIR} --webui-key ${SRCWEBUIKEY} -c ${SRCKNIFERB} --purge --concurrency ${BACKUPCONCURRENCY} 2>&1 | while IFS= read -r line; do echo "$(date) $line"; done >> ${BACKUPLOG}
echo "-- BACKUP FINISHED --" >> ${BACKUPLOG}
}
function runrestore () {
echo "-- RESTORE STARTING --" >> ${RESTORELOG}
knife ec restore ${BACKUPDIR} --webui-key ${DSTWEBUIKEY} -c ${DSTKNIFERB} --purge 2>&1 | while IFS= read -r line; do echo "$(date) $line"; done >> ${RESTORELOG}
echo "-- RESTORE FINISHED --" >> ${RESTORELOG}
}
case $1 in
'backup' )
runbackup ;;
'restore' )
runrestore ;;
* )
echo "Usage: $0 backup|restore"
esac
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
chef_server_url "https://chef-server.test/organizations/acmeinc"
ssl_verify_mode :verify_none
versioned_cookbooks true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment