backupUrl="https://$backupIp:8443/sdn/v2.0/backup" `get $backupIp $backupAuth $backupUrl > $fileName` expected=`get $nodeIP "v2.0/backup/checksum"` actual=$(sha256sum "$fileName" cut
echo "Checksum failure: expected $expected but got $actual." exitBackup 1
fi
teamBackup_log "Successfully copied backup MD5 file from $backupIp."
}
}
#Function verifyBackupStatus ( <nodeIndex> )
#Verifies the success of the backup.
function verifyBackupStatus { local nodeIndex=$1
local backupIP=${ipArr[$nodeIndex]}
local backupUrl="https://$backupIP:8443/sdn/v2.0/backup/status" backupStatus[$nodeIndex]=`get $backupIP ${nodeAuth[$nodeIndex]} $backupUrl` if [ "${backupStatus[$nodeIndex]}" == "SUCCESS" ]; then
teamBackup_log "Backup completed successfully on $backupIP." let "backup_complete = $backup_complete - 1"
return fi
}
# Function teamBackupZip ( )
# Creates a single zip for all the team backup data.
function teamBackupZip { teamZip=`datetr ' ' '_'tr ':' '_'`
teamZip="$BACKUP_TEAM_DIR/sdn_team_backup_$teamZip.zip"
rm
rm
}
# Function remoteBackupFileCopy ( )
# Copies the team backup zip to the specified remote location.
function remoteBackupFileCopy { if [ "$remotePath" == "" ]; then
teamBackup_log "Team backup data was not copied to the remote location." return
fi
teamBackup_log "Copying team backup to the remote location $remotePath..." scp $BACKUP_TEAM_DIR/sdn_team_backup* $remotePath
}
# Function getSysInfo ( <authToken> )
# Gets the SysInformation for the running node.
function getSysInfo { local leadAuth=$1
local sysUrl="https://localhost:8443/sdn/v2.0/systems" for i in {1..5}; do
sysInfo=`get localhost $leadAuth "$sysUrl"` if [ $errorCode
teamBackup_log "Failed to retrieve the system information." exitBackup 1
fi
[ "$sysInfo" != "" ] && break sleep 5
done
if [ "$sysInfo" == "" ]; then
teamBackup_log "Failed to retrieve the system information." exitBackup 1
fi
}
# Function extractRole_NodeIP ( <systemInfo>)
# Extracts IP and role for all the nodes in a team.
function extractRole_NodeIP { sysinfo=$1
ipArr=($(echo $sysinfotr
teamBackup_log "Number of nodes in the team is $numNodes." for (( i=0; i<=$numNodes; i++ )); do
if [ "${roleArr[$i]}" == "leader" ]; then leaderIp=${ipArr[$i]}
teamBackup_log "The team leader is $leaderIp." break
B.2 Backing up a controller team 123