mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-11 07:25:47 +08:00
Upgrade process fixes for linux
This commit is contained in:
parent
7a03de065d
commit
69d41de897
5 changed files with 16 additions and 8 deletions
|
@ -38,7 +38,13 @@ mkdir /opt/upgrade_server_root
|
|||
|
||||
## Provisioning files
|
||||
|
||||
Basically, upgrade_server servers zipped versions of NPBackup, than can directly be downloaded from git releases
|
||||
Basically, upgrade_server serves zipped versions of NPBackup, than can directly be downloaded from git releases. Those zipped files will contain a single directory, like `npbackup-gui` or `npbackup-cli` which contain all the files.
|
||||
|
||||
Additionally, fiels can be created converted from .tar.gz to zip with the following
|
||||
```
|
||||
tar xvf npbackup-linux-x64-cli-public.tar.gz
|
||||
zip -9 -r npbackup-cli.zip npbackup-cli
|
||||
```
|
||||
|
||||
When uploading new versions, you need to create a file in the data root called `VERSION` which should contain current NPBackup version, example `3.0.1`
|
||||
This way, every NPBackup client will download this file and compare with it's current version in order to verify if an upgrade is needed.
|
||||
|
|
|
@ -7,7 +7,7 @@ ofunctions.process>=2.0.0
|
|||
ofunctions.threading>=2.2.0
|
||||
ofunctions.platform>=1.5.1
|
||||
ofunctions.random
|
||||
ofunctions.requestor>=1.2.1
|
||||
ofunctions.requestor>=1.2.2
|
||||
python-pidfile>=3.0.0
|
||||
# pysimplegui 5 has gone commercial, let's switch to freesimplegui
|
||||
# also, we need to stick to freesimplegui 5.1.1 to keep Python 3.6 compat in order compile for elder linuxes
|
||||
|
|
|
@ -188,7 +188,7 @@ def auto_upgrader(
|
|||
# eg /tmp/npbackup_upgrade_dist/npbackup-cli
|
||||
upgrade_dist = os.path.join(tempfile.gettempdir(), "npbackup_upgrade_dist")
|
||||
try:
|
||||
# File should contain a single directory 'npbackup-cli' or 'npbackup-gui' with all files in it
|
||||
# File is a zip and should contain a single directory 'npbackup-cli' or 'npbackup-gui' with all files in it
|
||||
shutil.unpack_archive(downloaded_archive, upgrade_dist)
|
||||
except Exception as exc:
|
||||
logger.critical(f"Upgrade failed. Cannot uncompress downloaded dist: {exc}")
|
||||
|
@ -219,7 +219,7 @@ def auto_upgrader(
|
|||
f'"{CURRENT_EXECUTABLE}" --version >> {log_file} 2>&1 & '
|
||||
f"IF %ERRORLEVEL% NEQ 0 ( "
|
||||
f'echo "New executable failed. Rolling back" >> {log_file} 2>&1 && '
|
||||
f"rd /S /Q {CURRENT_DIR} >> {log_file} 2>&1 && "
|
||||
f"rd /S /Q "{CURRENT_DIR}" >> {log_file} 2>&1 && "
|
||||
f'move /Y "{backup_dist}" "{CURRENT_DIR}" >> {log_file} 2>&1 '
|
||||
f") ELSE ( "
|
||||
f'echo "Upgrade successful" >> {log_file} 2>&1 && '
|
||||
|
@ -237,10 +237,10 @@ def auto_upgrader(
|
|||
f'echo "Moving upgraded dist from {upgrade_dist} to {CURRENT_DIR}" >> {log_file} 2>&1 && '
|
||||
f'mv -f "{upgrade_dist}" "{CURRENT_DIR}" >> {log_file} 2>&1 && '
|
||||
f'echo "Adding executable bit to new executable" >> {log_file} 2>&1 && '
|
||||
f'chmod +x {CURRENT_EXECUTABLE}" >> {log_file} 2>&1 && '
|
||||
f'chmod +x "{CURRENT_EXECUTABLE}" >> {log_file} 2>&1 && '
|
||||
f'echo "Loading new executable {CURRENT_EXECUTABLE} --version" >> {log_file} 2>&1 && '
|
||||
f'"{CURRENT_EXECUTABLE}" --version >> {log_file} 2>&1; '
|
||||
f'"if [ $? -ne 0 ]; then '
|
||||
f'if [ $? -ne 0 ]; then '
|
||||
f'echo "New executable failed. Rolling back" >> {log_file} 2>&1 && '
|
||||
f'rm -f "{CURRENT_DIR}" >> {log_file} 2>&1 && '
|
||||
f'mv -f "{backup_dist}" "{CURRENT_DIR}" >> {log_file} 2>&1; '
|
||||
|
|
|
@ -174,6 +174,8 @@ async def upgrades(
|
|||
except KeyError:
|
||||
logger.error("No statistics file set.")
|
||||
|
||||
# TODO:
|
||||
# This can be amended by adding specific rules for host identity or groups or installed
|
||||
file = FileGet(platform=platform, arch=arch)
|
||||
try:
|
||||
result = crud.get_file(file)
|
||||
|
|
|
@ -7,7 +7,7 @@ __intname__ = "npbackup.upgrade_server.models.files"
|
|||
__author__ = "Orsiris de Jong"
|
||||
__copyright__ = "Copyright (C) 2023-2024 NetInvent"
|
||||
__license__ = "GPL-3.0-only"
|
||||
__build__ = "202303101"
|
||||
__build__ = "2024112601"
|
||||
|
||||
|
||||
from enum import Enum
|
||||
|
@ -16,7 +16,7 @@ from pydantic import BaseModel, constr
|
|||
|
||||
class Platform(Enum):
|
||||
windows = "windows"
|
||||
linux = "Linux"
|
||||
linux = "linux"
|
||||
|
||||
|
||||
class Arch(Enum):
|
||||
|
|
Loading…
Add table
Reference in a new issue