-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fixed backup path detection and optimized output log file names #12454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a017630
Fixed backup path detection and optimized output log file names
CloudWise-Lukemiao 85bf69c
spotless
CloudWise-Lukemiao 34cbd61
Merge branch 'master' of https://github.com/apache/iotdb into master_…
CloudWise-Lukemiao 0227dd3
Fixed issues with non-standard naming of backup data directories and …
CloudWise-Lukemiao 662b504
add logback
CloudWise-Lukemiao ae4cdc5
add logback
CloudWise-Lukemiao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
iotdb-client/cli/src/assembly/resources/tools/backup.bat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| @REM | ||
| @REM Licensed to the Apache Software Foundation (ASF) under one | ||
| @REM or more contributor license agreements. See the NOTICE file | ||
| @REM distributed with this work for additional information | ||
| @REM regarding copyright ownership. The ASF licenses this file | ||
| @REM to you under the Apache License, Version 2.0 (the | ||
| @REM "License"); you may not use this file except in compliance | ||
| @REM with the License. You may obtain a copy of the License at | ||
| @REM | ||
| @REM http://www.apache.org/licenses/LICENSE-2.0 | ||
| @REM | ||
| @REM Unless required by applicable law or agreed to in writing, | ||
| @REM software distributed under the License is distributed on an | ||
| @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| @REM KIND, either express or implied. See the License for the | ||
| @REM specific language governing permissions and limitations | ||
| @REM under the License. | ||
| @REM | ||
|
|
||
| @echo off | ||
| setlocal enabledelayedexpansion | ||
|
|
||
| if "%OS%" == "Windows_NT" setlocal | ||
|
|
||
| pushd %~dp0.. | ||
| if NOT DEFINED IOTDB_HOME set IOTDB_HOME=%CD% | ||
| popd | ||
|
|
||
| if NOT DEFINED JAVA_HOME goto :err | ||
|
|
||
| set JAVA_OPTS=-ea^ | ||
| -DIOTDB_HOME="%IOTDB_HOME%" | ||
|
|
||
| SET IOTDB_CONF=%IOTDB_HOME%\conf | ||
| IF EXIST "%IOTDB_CONF%\datanode-env.bat" ( | ||
| CALL "%IOTDB_CONF%\datanode-env.bat" > nul 2>&1 | ||
| ) ELSE ( | ||
| echo Can't find datanode-env.bat | ||
| ) | ||
|
|
||
| IF EXIST "%IOTDB_CONF%\iotdb-datanode.properties" ( | ||
| for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_rpc_port" | ||
| "%IOTDB_CONF%\iotdb-datanode.properties"') do ( | ||
| set dn_rpc_port=%%i | ||
| ) | ||
| ) ELSE ( | ||
| set dn_rpc_port=6667 | ||
| ) | ||
|
|
||
| IF EXIST "%IOTDB_CONF%\iotdb-confignode.properties" ( | ||
| for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^cn_internal_port" | ||
| "%IOTDB_CONF%\iotdb-confignode.properties"') do ( | ||
| set cn_internal_port=%%i | ||
| ) | ||
| ) ELSE ( | ||
| set cn_internal_port=10710 | ||
| ) | ||
|
|
||
| set "local_iotdb_occupied_ports=" | ||
| set "operation_dirs=" | ||
| set dn_rpc_port_occupied=0 | ||
| set cn_internal_port_occupied=0 | ||
|
|
||
| for /f "tokens=1,3,7 delims=: " %%i in ('netstat /ano') do ( | ||
| if %%i==TCP ( | ||
| if %%j==%dn_rpc_port% ( | ||
| if !dn_rpc_port_occupied!==0 ( | ||
| set spid=%%k | ||
| call :checkIfIOTDBProcess !spid! is_iotdb | ||
| if !is_iotdb!==1 ( | ||
| set local_iotdb_occupied_ports=%dn_rpc_port% !local_iotdb_occupied_ports! | ||
| ) | ||
| ) | ||
|
|
||
| ) else if %%j==%cn_internal_port% ( | ||
| if !cn_internal_port_occupied!==0 ( | ||
| set spid=%%k | ||
| call :checkIfIOTDBProcess !spid! is_iotdb | ||
| if !is_iotdb!==1 ( | ||
| set local_iotdb_occupied_ports=%cn_internal_port% !local_iotdb_occupied_ports! | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| if defined local_iotdb_occupied_ports ( | ||
| goto :checkFail | ||
| ) | ||
| echo ------------------------------------------ | ||
| echo Starting IoTDB Client Data Back Script | ||
| echo ------------------------------------------ | ||
|
|
||
| set CLASSPATH="%IOTDB_HOME%\lib\*" | ||
| if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.tool.IoTDBDataBackTool | ||
|
|
||
| set logsDir="%IOTDB_HOME%\logs" | ||
| if not exist "%logsDir%" ( | ||
| mkdir "%logsDir%" | ||
| ) | ||
|
|
||
| set IOTDB_CLI_CONF=%IOTDB_HOME%\conf | ||
| set "iotdb_cli_params=-Dlogback.configurationFile=!IOTDB_CLI_CONF!\logback-cli.xml" | ||
| start /B "" cmd /C "("%JAVA_HOME%\bin\java" -DIOTDB_HOME=!IOTDB_HOME! !iotdb_cli_params! !JAVA_OPTS! -cp !CLASSPATH! !MAIN_CLASS! %*) > nul 2>&1" | ||
| exit /b | ||
|
|
||
| :checkIfIOTDBProcess | ||
| setlocal | ||
|
|
||
| set "pid_to_check=%~1" | ||
| set "is_iotdb=0" | ||
|
|
||
| for /f "usebackq tokens=*" %%i in (`wmic process where "ProcessId=%pid_to_check%" get CommandLine /format:list ^| findstr /c:"CommandLine="`) do ( | ||
| set command_line=%%i | ||
| ) | ||
| echo %command_line% | findstr /i /c:"iotdb" >nul && set is_iotdb=1 | ||
| endlocal & set "is_iotdb=%is_iotdb%" | ||
| exit /b | ||
|
|
||
| :err | ||
| echo JAVA_HOME environment variable must be set! | ||
| set ret_code=1 | ||
| exit /b | ||
|
|
||
| :checkFail | ||
| echo Please stop IoTDB | ||
| exit /b |
134 changes: 134 additions & 0 deletions
134
iotdb-client/cli/src/assembly/resources/tools/backup.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
| # | ||
|
|
||
| echo ------------------------------------------ | ||
| echo Starting IoTDB Client Data Back Script | ||
| echo ------------------------------------------ | ||
|
|
||
|
|
||
| if [ -z "${IOTDB_INCLUDE}" ]; then | ||
| #do nothing | ||
| : | ||
| elif [ -r "$IOTDB_INCLUDE" ]; then | ||
| . "$IOTDB_INCLUDE" | ||
| fi | ||
|
|
||
| if [ -z "${IOTDB_HOME}" ]; then | ||
| export IOTDB_HOME="$(cd "`dirname "$0"`"/..; pwd)" | ||
| fi | ||
|
|
||
| if [ -n "$JAVA_HOME" ]; then | ||
| for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do | ||
| if [ -x "$java" ]; then | ||
| JAVA="$java" | ||
| break | ||
| fi | ||
| done | ||
| else | ||
| JAVA=java | ||
| fi | ||
|
|
||
| if [ -z $JAVA ] ; then | ||
| echo Unable to find java executable. Check JAVA_HOME and PATH environment variables. > /dev/stderr | ||
| exit 1; | ||
| fi | ||
|
|
||
| datanodeclassname=org.apache.iotdb.db.service.DataNode | ||
|
|
||
| confignodeclassname=org.apache.iotdb.db.service.ConfigNode | ||
|
|
||
| check_tool_env() { | ||
| if ! type lsof > /dev/null 2>&1 ; then | ||
| echo "" | ||
| echo " Warning: No tool 'lsof', Please install it." | ||
| echo " Note: Some checking function need 'lsof'." | ||
| echo "" | ||
| return 1 | ||
| else | ||
| return 0 | ||
| fi | ||
| } | ||
|
|
||
| get_properties_value() { | ||
| local file_name=$1 | ||
| local property_name=$2 | ||
| local default_value=$3 | ||
| local property_value=$(sed "/^${property_name}=/!d;s/.*=//" "${IOTDB_HOME}/conf/${file_name}.properties") | ||
| if [ -z "$property_value" ]; then | ||
| property_value="$default_value" | ||
| fi | ||
| echo "$property_value" | ||
| } | ||
| iotdb_listening_ports=() | ||
| check_running_process() { | ||
| DATANODE="iotdb-datanode" | ||
| CONFIGNODE="iotdb-confignode" | ||
| dn_rpc_port=$(get_properties_value $DATANODE "dn_rpc_port" "6667") | ||
| cn_internal_port=$(get_properties_value $CONFIGNODE "cn_internal_port" "10710") | ||
| local_ports+=("$dn_rpc_port") | ||
| local_ports+=("$cn_internal_port") | ||
| for port in "${local_ports[@]}"; do | ||
| # Check if lsof command is available | ||
| if command -v lsof >/dev/null 2>&1; then | ||
| listening=$(lsof -i :$port -sTCP:LISTEN -P -n | grep LISTEN) | ||
| if [ -n "$listening" ]; then | ||
| process_command=$(echo "$listening" | awk '{print $2}') | ||
| iotdb_check=$(ps -p "$process_command" -o args= | grep "iotdb") | ||
| if [ -n "$iotdb_check" ]; then | ||
| iotdb_listening_ports+=("$port ") | ||
| fi | ||
| fi | ||
| elif command -v netstat >/dev/null 2>&1; then | ||
| listening=$(netstat -tln | awk '{print $4}' | grep ":$port$") | ||
| if [ -n "$listening" ]; then | ||
| process_command=$(echo "$listening" | awk '{print $2}') | ||
| iotdb_check=$(ps -p "$process_command" -o args= | grep "iotdb") | ||
| if [ -n "$iotdb_check" ]; then | ||
| iotdb_listening_ports+=("$port ") | ||
| fi | ||
| fi | ||
| else | ||
| echo "Error: Unable to detect port occupation. Please install 'lsof' or 'netstat' command." | ||
| exit 1 | ||
| fi | ||
| done | ||
| if [ ${#iotdb_listening_ports[@]} -gt 0 ]; then | ||
| echo " Please stop IoTDB" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| check_running_process | ||
|
|
||
| for f in ${IOTDB_HOME}/lib/*.jar; do | ||
| CLASSPATH=${CLASSPATH}":"$f | ||
| done | ||
|
|
||
| MAIN_CLASS=org.apache.iotdb.tool.IoTDBDataBackTool | ||
|
|
||
| logs_dir="${IOTDB_HOME}/logs" | ||
|
|
||
| if [ ! -d "$logs_dir" ]; then | ||
| mkdir "$logs_dir" | ||
| fi | ||
|
|
||
| IOTDB_CLI_CONF=${IOTDB_HOME}/conf | ||
| iotdb_cli_params="-Dlogback.configurationFile=${IOTDB_CLI_CONF}/logback-cli.xml" | ||
| exec nohup "$JAVA" -DIOTDB_HOME=${IOTDB_HOME} $iotdb_cli_params -cp "$CLASSPATH" "$MAIN_CLASS" "$@" 2>&1 > /dev/null <&- & |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.