From 80cbbc8710292ae08437daa6e3390cc0190e3139 Mon Sep 17 00:00:00 2001 From: "Chou, Joseph (JC2555)" Date: Mon, 2 Apr 2018 14:11:34 -0400 Subject: ONAP log files consolidation Check in changes for pap,pdp,console,brmsgw,paplp and pdplp Change-Id: I23525a44e0f269d04d9870c3eed18b6b8daacb2c Issue-ID: POLICY-562 Signed-off-by: Chou, Joseph (JC2555) --- .../base/src/files/install/mysql/bin/db_restore.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'packages/base/src/files/install/mysql/bin/db_restore.sh') diff --git a/packages/base/src/files/install/mysql/bin/db_restore.sh b/packages/base/src/files/install/mysql/bin/db_restore.sh index 0f63535c7..765b0cad3 100644 --- a/packages/base/src/files/install/mysql/bin/db_restore.sh +++ b/packages/base/src/files/install/mysql/bin/db_restore.sh @@ -38,6 +38,8 @@ BACKUP_FILE="" DATABASE="" TABLE="" TEMP_FILE=/tmp/db_restore_$$.sql +DATE=`date +"%Y%m%d"` +LOG="" function restore_all { @@ -54,7 +56,7 @@ function restore_table { database="${1}" table="${2}" - echo "restore_table [$database] [$table] started ...@`date`" + echo "restore_table [$database] [$table] started ...@`date`" | tee -a $LOG # extract sql statement from backup file echo "use $database;" > $TEMP_FILE echo "set foreign_key_checks=0; " >> $TEMP_FILE @@ -66,12 +68,18 @@ function restore_table echo "Before restore table ..." | tee -a $LOG mysql -u${DB_USER} -p${DB_PASSWORD} < $TEMP_FILE echo "--" - echo "restore_table [$database] [$table] completed ...@`date`" + echo "restore_table [$database] [$table] completed ...@`date`" | tee -a $LOG } # MAIN -echo "db_restore.sh started ... `date`" +if [ -z ${POLICY_LOGS} ]; then + POLICY_LOGS=/var/log/onap +fi +mkdir -p $POLICY_LOGS/policy/db +LOG=$POLICY_LOGS/policy/db/db_restore_$DATE.log + +echo "db_restore.sh started ... `date`" | tee -a $LOG if [ $# -eq 5 ]; then DB_USER="${1}" DB_PASSWORD="${2}" @@ -86,7 +94,7 @@ if [ $# -eq 5 ]; then restore_all fi else - echo "BACKUP FILE NOT FOUND: $BACKUP_FILE" + echo "BACKUP FILE NOT FOUND: $BACKUP_FILE" | tee -a $LOG fi else echo "Usage : db_restore.sh db_user_id db_password backup_file database table_name" @@ -94,4 +102,4 @@ else fi rm -f $TEMP_FILE -echo "db_restore.sh completed ... `date`" +echo "db_restore.sh completed ... `date`" | tee -a $LOG -- cgit 1.2.3-korg