-
Notifications
You must be signed in to change notification settings - Fork 7
Setup & use the upgrade server
NPBackup has an integrated autoupgrade function that allows clients to fetch newer binaries.
Easiest way to setup the upgrade server is to download it from git and setup a separate python virtual environment for it, using a dedicated user:
export USERNAME=npbackup
export SERVER_ROOT=/var/npbackup_upgrade_server
export PYTHON_ROOT=/opt/upgrade_server
# Create service user
useradd --no-create-home --system ${USERNAME}
cd /tmp
git clone https://github.com/netinvent/npbackup
mkdir -p "${SERVER_ROOT}/dist"
mkdir -p "${PYTHON_ROOT}"
cp -R npbackup/upgrade_server/* "${SERVER_ROOT}/"
python -m venv "${PYTHON_ROOT}/venv"
"${PYTHON_ROOT}/venv/bin/python" -m pip install -r "${SERVER_ROOT}/requirements.txt"Once you're done, setup the upgrade_server conf file
cp /tmp/npbackup/examples/upgrade_server/npbackup_upgrade_server.conf.dist /etc/npbackup_upgrade_server.confSetup adequate rights
chown ${USERNAME}:${USERNAME} "${SERVER_ROOT}"
chmod 775 -R "${SERVER_ROOT}"
chmod 775 -R "${PYTHON_ROOT}"
chown ${USERNAME}:${USERNAME} /etc/npbackup_upgrade_server.confAt this point, you should customize the server conf file, at least for http server username and password entries.
Once you're done, you can setup a systemd service with
cp /tmp/npbackup/examples/systemd/npbackup_upgrade_server.service /etc/systemd/system
systemctl enable npbackup_upgrade_server
systemctl start npbackup_upgrade_serverThe server now running, you can check it with the following
curl localhost:8080/status
Don't forget to create the corresponding firewall rule for your server to be accessible
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload
The upgrades are served from the dist dir, in our case /var/npbackup_upgrade_server/dist directory.
Basically, upgrade_server serves archives versions of NPBackup, than can directly be downloaded from git releases. Those compressed files will contain a single directory, like npbackup-gui or npbackup-cli which contain all the files (.zip and .tar.gz files are supported)
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.
If an upgrade is needed, NPBackup will try to download it from /download/{platform}/{arch}/{build_type}/{audience}
Current platforms are: windows, linux
Current arches are x64, x64-legacy, x86-legacy, arm-legacy and arm64-legacy.
Build types are gui, cli and viewer.
Audiences are: public, private.
Basically, if you want to update the current NPBackup client, you should have copy your new npbackup archives to the according locations
/var/npbackup_upgrade_serfver/dist/VERSION
/var/npbackup_upgrade_server/dist/npbackup-linux-x64-cli-public.tar.gz
/var/npbackup_upgrade_server/dist/npbackup-windows-x64-gui-public.zip
Keep in mind that the dist directory and all it's content need to be readable (but not writable) by the npbackup user.
Sometimes, specific hosts, client versions or client groups might need targeted upgrades.
If found, the following subdirectories will be the prefered source of upgrade files, and will be searched in that order:
/var/npbackup_upgrade_server/dist/{host_identity}/npbackup-linux-x64-gui-public.tar.gz
/var/npbackup_upgrade_server/dist/{current_version}/npbackup-linux-x64-viewer-public.tar.gz
/var/npbackup_upgrade_server/dist/{group}/npbackup-windows-x64-cli-public.zip
Note that if those directories exist but are empty, upgrade process will fail.
Also note that a VERSION file must exist in the same subdirectory as the upgrade archive.
Whenever you want to disable upgrade service but still keep track of connections, you may add an empty file called DISABLED in the server root, ie /var/npbackup_upgrade_server/dist/DISABLED.