update hanatool
This commit is contained in:
18
hanatool.sh
18
hanatool.sh
@@ -3,7 +3,7 @@
|
||||
# ==============================================================================
|
||||
# SAP HANA Schema Management Tool (hanatool.sh)
|
||||
#
|
||||
# A command-line utility to quickly export, restore, or import-and-rename
|
||||
# A command-line utility to quickly export, restore, or restore-and-rename
|
||||
# a SAP HANA schema.
|
||||
# ==============================================================================
|
||||
|
||||
@@ -17,17 +17,17 @@ usage() {
|
||||
echo "SAP HANA Schema Management Tool"
|
||||
echo ""
|
||||
echo "Usage: $0 [USER_KEY] [ACTION] [SCHEMA_NAME] [PATH] [OPTIONS]"
|
||||
echo " $0 [USER_KEY] import-rename [SCHEMA_NAME] [NEW_SCHEMA_NAME] [PATH] [OPTIONS]"
|
||||
echo " $0 [USER_KEY] restore-rename [SCHEMA_NAME] [NEW_SCHEMA_NAME] [PATH] [OPTIONS]"
|
||||
echo ""
|
||||
echo "Actions:"
|
||||
echo " export Export a schema to a specified path."
|
||||
echo " restore Restore a schema from a specified path."
|
||||
echo " import-rename Restore a schema from a path to a new schema name."
|
||||
echo " restore-rename Restore a schema from a path to a new schema name."
|
||||
echo ""
|
||||
echo "Arguments:"
|
||||
echo " USER_KEY The user key from hdbuserstore for DB connection."
|
||||
echo " SCHEMA_NAME The name of the source schema."
|
||||
echo " NEW_SCHEMA_NAME (Required for import-rename only) The target schema name."
|
||||
echo " NEW_SCHEMA_NAME (Required for restore-rename only) The target schema name."
|
||||
echo " PATH The file system path for the export/import data."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
@@ -44,7 +44,7 @@ usage() {
|
||||
echo " $0 MYKEY restore MYSCHEMA /hana/backups/MYSCHEMA_20240101.tar.gz -c"
|
||||
echo ""
|
||||
echo " # Import MYSCHEMA as MYSCHEMA_TEST using a custom hdbsql path"
|
||||
echo " $0 MYKEY import-rename MYSCHEMA MYSCHEMA_TEST /hana/backups/temp_export --hdbsql /sap/custom/hdbsql"
|
||||
echo " $0 MYKEY restore-rename MYSCHEMA MYSCHEMA_TEST /hana/backups/temp_export --hdbsql /sap/custom/hdbsql"
|
||||
}
|
||||
|
||||
# --- Argument Parsing ---
|
||||
@@ -153,7 +153,7 @@ case "$ACTION" in
|
||||
fi
|
||||
;;
|
||||
|
||||
restore|import-rename)
|
||||
restore|restore-rename)
|
||||
if [[ "$ACTION" == "restore" ]]; then
|
||||
SOURCE_PATH="$4"
|
||||
NEW_SCHEMA_NAME=""
|
||||
@@ -162,11 +162,11 @@ case "$ACTION" in
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
else # import-rename
|
||||
else # restore-rename
|
||||
NEW_SCHEMA_NAME="$4"
|
||||
SOURCE_PATH="$5"
|
||||
if [[ -z "$USER_KEY" || -z "$SCHEMA_NAME" || -z "$NEW_SCHEMA_NAME" || -z "$SOURCE_PATH" ]]; then
|
||||
echo "❌ Error: Missing arguments for 'import-rename' action."
|
||||
echo "❌ Error: Missing arguments for 'restore-rename' action."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
@@ -205,7 +205,7 @@ case "$ACTION" in
|
||||
fi
|
||||
|
||||
QUERY_RENAME_PART=""
|
||||
if [[ "$ACTION" == "import-rename" ]]; then
|
||||
if [[ "$ACTION" == "restore-rename" ]]; then
|
||||
QUERY_RENAME_PART="WITH RENAME SCHEMA \"${SCHEMA_NAME}\" TO \"${NEW_SCHEMA_NAME}\""
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user