Administrator's Guide
break
fi
sleep 10
for (( i=0; i<$numNodes; i++ )); do
# Skip the leader node check, since it will be done last.
[ "${ipArr[$i]}" == "$leaderIp" ] && continue
# Backup already completed for this node, so continue.
[ "${backupStatus[$i]}" == "SUCCESS" ] && continue
verifyBackupStatus $i
done
done
if [ $backup_complete -gt 1 ]; then
teamBackup_log "Backup of all member nodes took longer than $waitTime min. Aborting backup..."
teamBackup_log "To increase backup wait time, change BACKUP_WAIT_COUNT in the script."
exitBackup 1
fi
# Last, backup the leader node to avoid synchronization issues on a restore.
backupNode $leaderIndex
teamBackup_log "Started backup on leader ${ipArr[$leaderIndex]}."
backup_complete=1
# Verify the backup on the leader node.
for (( k=0; k<$BACKUP_WAIT_COUNT; k++ )); do
sleep 10
verifyBackupStatus $leaderIndex
if [ $backup_complete -le 0 ]; then
teamBackup_log "Backup on the leader node completed successfully."
break
fi
done
if [ $backup_complete -gt 0 ]; then
teamBackup_log "Backup of the leader node took longer than $waitTime min. Aborting backup..."
teamBackup_log "To increase backup wait time, change BACKUP_WAIT_COUNT in the script."
exitBackup 1
fi
# Copy all the backup files from each node in the team onto the leader node.
for (( i=0; i<$numNodes; i++ )); do
downloadBackupSet $i
done
# Create one zip for entire team and copy it to the specified remote location.
teamBackupZip
remoteBackupFileCopy
echo
teamBackup_log "The team was backed up successfully."
exitBackup 0
B.3 Restoring a controller team
NOTE: Before running this script, re-install the controller. Otherwise an Error 404 condition results
and the controller is not restored. See “Restoring a controller from a backup ” (page 95).
Because the scripts in this appendix cross page boundaries, be careful to avoid including the page
number when copying a script. Copying a script one page at a time can prevent inclusion of page
numbers.
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright 2013 Hewlett Packard Co., All Rights Reserved.
#-------------------------------------------------------------------------------
#
# Restore a Team
#-------------------------------------------------------------------------------
export BACKUP_DIR="/opt/sdn/backup"
export BACKUP_TEAM_DIR="/opt/sdn/team_backup"
export RESTORE_TEAM_DIR="/opt/sdn/team_restore"
export TEAM_BACKUP_STATUS_FILE="$RESTORE_TEAM_DIR/teamRestore_status"
export TEAM_BACKUP_LOGFILE="$RESTORE_TEAM_DIR/teamRestore_log.log"
export RESTORE_BACKUP_FILESET="$RESTORE_TEAM_DIR/opt/sdn/team_backup"
export B_PID=$$
trap "exit 1" TERM
#==============================================================================
# F U N C T I O N S
#==============================================================================
#------------------------------------------------------------------------------
# Function extract_zip_and_ip ( )
# Extracts the team backup zip and the backed up IP addresses.
#------------------------------------------------------------------------------
function extract_zip_and_ip {
unzip -o "$RESTORE_TEAM_DIR/sdn_team_backup*" -d $RESTORE_TEAM_DIR
if [ $? -ne 0 ]; then
teamBackup_log "Failed to unzip the team backup file."
126 Scripts