2438ad03ab
This change adds upgrade tooling that will take a Juno based OpenStack-Ansible cloud and upgrade it to Newton. The tooling will run a deployment through all of the needed steps upgrading the environment and skipping all of the OpenStack releases in between. **This tooling should be considered experimental at this time** Change-Id: I1880794717b9e47786ae255ea1afa57d805cde8e Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
59 lines
2.0 KiB
Bash
59 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
# Copyright 2017, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# Set the full path to the MYSQL commands
|
|
|
|
## Shell Opts ----------------------------------------------------------------
|
|
set -e -u -v
|
|
|
|
MYSQLDUMP=$(which mysqldump)
|
|
MYSQL=$(which mysql)
|
|
TAR=$(which tar)
|
|
|
|
# If a my.cnf file is not found, force the user to enter the mysql root password
|
|
if [ ! -f "${HOME}/.my.cnf" ];then
|
|
echo -e "No \".my.cnf\" in \"${HOME}\". You are going to need the MySQL Root password."
|
|
MYSQL="${MYSQL} -u root -p"
|
|
MYSQLDUMP="${MYSQLDUMP} -u root -p"
|
|
fi
|
|
|
|
# return a list of databases to backup
|
|
DB_NAMES=$(${MYSQL} -Bse "show databases;" | grep -v -e "schema" -e "mysql")
|
|
|
|
# Set the backup directory
|
|
DB_BACKUP_DIR=${DB_BACKUP_DIR:-"/var/backup"}
|
|
|
|
# Go to the Database Backup Dir
|
|
pushd ${DB_BACKUP_DIR}
|
|
# Backup all databases individually
|
|
for db in ${DB_NAMES};do
|
|
echo "Performing a Database Backup on ${db}"
|
|
if [ -f "${db}.sql" ];then
|
|
echo "Moving old Database Backup to ${db}.sql.old"
|
|
mv ${db}.sql ${db}.backup-$(date +%y%m%d-%H%M%S).sql
|
|
fi
|
|
${MYSQLDUMP} ${db} > ${db}.sql
|
|
done
|
|
# Create an archive of the new backup.
|
|
echo "Creating an Archive of the Database Backup Directory"
|
|
if [ -f "OpenstackDatabases.tgz" ];then
|
|
echo "Moving old Database archive to OpenstackDatabases.tgz.old"
|
|
mv OpenstackDatabases.tgz OpenstackDatabases.tgz.old
|
|
fi
|
|
${TAR} -cvzf OpenstackDatabases-$(date +%y%m%d).tgz ${DB_BACKUP_DIR}/*.sql
|
|
echo "Done."
|
|
popd
|
|
|
|
exit 0
|