mirror of
https://github.com/netinvent/npbackup.git
synced 2025-10-06 19:46:58 +08:00
upgrade_server: Fix upgrade script
This commit is contained in:
parent
7ee603374e
commit
f582f52447
1 changed files with 9 additions and 7 deletions
|
@ -20,37 +20,39 @@ echo "Launching upgrade" >> "{log_file}" 2>&1
|
|||
echo "Moving current dist from {CURRENT_DIR} to {backup_dist}" >> "{log_file}" 2>&1
|
||||
move /Y "{CURRENT_DIR}" "{backup_dist}" >> "{log_file}" 2>&1 || GOTO MOVE_FAILED
|
||||
GOTO MOVE_OK
|
||||
:: MOVE_FAILED
|
||||
:MOVE_FAILED
|
||||
echo "Moving current dist failed. Trying to copy it." >> "{log_file}" 2>&1
|
||||
xcopy /S /Y /I "{CURRENT_DIR}\*" "{backup_dist}" >> "{log_file}" 2>&1
|
||||
echo "Now trying to overwrite current dist with upgrade dist" >> "{log_file}" 2>&1
|
||||
xcopy /S /Y /I "{upgrade_dist}\*" "{CURRENT_DIR}" >> "{log_file}" 2>&1
|
||||
GOTO TESTRUN
|
||||
:: MOVE_OK
|
||||
:MOVE_OK
|
||||
echo "Moving upgraded dist from {upgrade_dist} to {CURRENT_DIR}" >> "{log_file}" 2>&1
|
||||
move /Y "{upgrade_dist}" "{CURRENT_DIR}" >> "{log_file}" 2>&1
|
||||
echo "Copying optional configuration files from {backup_dist} to {CURRENT_DIR}" >> "{log_file}" 2>&1
|
||||
xcopy /S /Y /I "{backup_dist}\*conf" {CURRENT_DIR} > NUL 2>&1
|
||||
GOTO TESTRUN
|
||||
:: TESTRUN
|
||||
:TESTRUN
|
||||
echo "Loading new executable {CURRENT_EXECUTABLE} --run-as-cli --check-config {original_args}" >> "{log_file}" 2>&1
|
||||
"{CURRENT_EXECUTABLE}" --run-as-cli --check-config {original_args} >> "{log_file}" 2>&1 || GOTO FAILED_TEST_RUN
|
||||
GOTO RUN_AS_PLANNED
|
||||
:: FAILED_TEST_RUN
|
||||
GOTO TEST_RUN_OK
|
||||
:FAILED_TEST_RUN
|
||||
echo "New executable failed. Rolling back" >> "{log_file}" 2>&1
|
||||
echo "Trying to move back" >> "{log_file}" 2>&1
|
||||
move /Y "{CURRENT_DIR}" "{backup_dist}.original" >> "{log_file}" 2>&1 || GOTO MOVE_BACK_FAILED
|
||||
move /Y "{backup_dist}" "{CURRENT_DIR}" >> "{log_file}" 2>&1
|
||||
GOTO RUN_AS_PLANNED
|
||||
:: MOVE_BACK_FAILED
|
||||
:MOVE_BACK_FAILED
|
||||
echo "Moving files back failed. Trying to overwrite" >> "{log_file}" 2>&1
|
||||
xcopy /S /Y /I "{backup_dist}\*" "{CURRENT_DIR}" >> "{log_file}" 2>&1
|
||||
GOTO RUN_AS_PLANNED
|
||||
:: RUN_AS_PLANNED
|
||||
:TEST_RUN_OK
|
||||
echo "Upgrade successful" >> "{log_file}" 2>&1
|
||||
rd /S /Q "{backup_dist}" >> "{log_file}" 2>&1
|
||||
rd /S /Q "{upgrade_dist}" > NUL 2>&1
|
||||
del /F /S /Q "{downloaded_archive}" >> "{log_file}" 2>&1
|
||||
GOTO RUN_AS_PLANNED
|
||||
:RUN_AS_PLANNED
|
||||
echo "Running as initially planned:" >> "{log_file}" 2>&1
|
||||
echo "{CURRENT_EXECUTABLE} {original_args}" >> "{log_file}" 2>&1
|
||||
"{CURRENT_EXECUTABLE}" {original_args}
|
||||
|
|
Loading…
Add table
Reference in a new issue