<<< Rasberry Pi Guides >>>
Upgrading WeeWX 4
The WeeWX software comes with an excellent in-situ upgrade process which is fully documented on the WeeWX website and for most people this is the best way to upgrade your system.
But I prefer to execute an Out-of-Place upgrade whereby the old directory structure is moved to a new location and a fresh install is carried out
This gives me a couple of benefits over the documented upgrade process
- I have a clean install with no "left-over" code that may inadvertantly effect the system
- It matches exactly what I have been testing in my development environment, which was created as a fresh install in a new Virtual Machine
- If something goes wrong, I can very quickly revert to the original system by deleting the new install and copying the original code back
And to facilitate this approach I utilise three environments
- Development - which is a Virtual Machine that I can build up and tear down as often as required till I am happy with the new version
- Pre-Prod/DR - which is a second Rasberry Pi where I test the release, but which also serves as a DR system should my primary system fail
- Production - which is my main Rasberry Pi and where WeeWX runs
Preperation
First, log onto your Rasberry Pi, stop WeeWX and backup your system
pi@raspberrypi:~ $ sudo systemctl stop weewx
pi@raspberrypi:~ $ ls -al /home/
total 16
drwxr-xr-x 4 root root 4096 Feb 18 14:39 .
drwxr-xr-x 18 root root 4096 Feb 18 08:00 ..
drwxr-xr-x 19 pi pi 4096 Feb 18 13:33 pi
drwxr-xr-x 9 pi pi 4096 Feb 12 13:40 weewx
pi@raspberrypi:~ $ sudo mv /home/weewx /home/weewx-Feb-2021
pi@raspberrypi:~ $ ls -al /home/
drwxr-xr-x 4 root root 4096 Feb 18 14:39 .
drwxr-xr-x 18 root root 4096 Feb 18 08:00 ..
drwxr-xr-x 19 pi pi 4096 Feb 18 13:33 pi
drwxr-xr-x 9 pi pi 4096 Feb 12 13:40 weewx-Feb-2021
Install Weewx
First get the source files
pi@raspberrypi:~ $ wget http://www.weewx.com/downloads/weewx-4.4.0.tar.gz
--2021-02-18 14:42:38-- http://www.weewx.com/downloads/weewx-4.4.0.tar.gz
Resolving www.weewx.com (www.weewx.com)... 34.218.218.142
Connecting to www.weewx.com (www.weewx.com)|34.218.218.142|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1607154 (1.5M) [application/octet-stream]
Saving to: 'weewx-4.4.0.tar.gz'
weewx-4.4.0.tar.gz 100%[==========================================================>] 1.53M 1.85MB/s in 0.8s
2021-02-18 14:42:39 (1.85 MB/s) - 'weewx-4.4.0.tar.gz' saved [1607154/1607154]
Then unpack the tar file and check the contents
pi@raspberrypi:~ $ tar xvfz weewx-4.4.0.tar.gz
pi@raspberrypi:~ $ ls -al weewx-4.4.0
total 116
drwxr-xr-x 7 pi pi 4096 Jan 30 18:52 .
drwxr-xr-x 20 pi pi 4096 Feb 18 14:43 ..
-rw-r--r-- 1 pi pi 32472 Apr 14 2020 LICENSE.txt
-rw-r--r-- 1 pi pi 396 Jan 30 18:52 PKG-INFO
-rw-r--r-- 1 pi pi 400 Apr 14 2020 README
-rw-r--r-- 1 pi pi 3325 Jan 8 21:10 README.md
drwxr-xr-x 10 pi pi 4096 Jan 30 18:52 bin
drwxr-xr-x 6 pi pi 4096 Jan 30 18:52 docs
drwxr-xr-x 8 pi pi 4096 Jan 30 18:52 examples
-rw-r--r-- 1 pi pi 330 Dec 1 12:47 setup.cfg
-rwxr-xr-x 1 pi pi 13121 Jan 30 13:54 setup.py
drwxr-xr-x 8 pi pi 4096 Jan 30 18:52 skins
drwxr-xr-x 15 pi pi 4096 Jan 30 18:52 util
-rw-r--r-- 1 pi pi 22426 Jan 30 13:54 weewx.conf
The next step is to build and install weewx
To specify a location different from the standard /home/weewx, modify the parameter home in the setup.cfg file.
Note: it is important to ensure you are using Python version 3
pi@raspberrypi:~ $ python -V
Python 3.7.3
pi@raspberrypi:~ $ cd weewx-4.4.0
pi@raspberrypi:~ $ python ./setup.py build
running build
running build_py
creating build
creating build/lib
.
.
.
changing mode of build/scripts-3.7/weewxd from 644 to 755
changing mode of build/scripts-3.7/wunderfixer from 644 to 755
pi@raspberrypi:~ $ sudo python ./setup.py install --no-prompt
running install
running build
running build_py
running build_scripts
running install_lib
.
.
.
running install_egg_info
Removing /home/weewx/bin/weewx-4.4.0.egg-info
Writing /home/weewx/bin/weewx-4.4.0.egg-info
Optionally Re-Set privileges
This is an optional step to set the privileges of the WeeWX code so that you can modify the files. By default, the WeeWX installation process leaves all files with root privileges and this precludes anyone other than root making changes.
For me this makes it difficult to deploy my modified scripts as I use the user pi rather than root to do this
The easiest way to do this is to set the ownership of the WeeWX files to be the user that you use to connect to your Rasberry Pi, which is pi in my case
pi@raspberrypi:~ $ ls -al /home/weewx
total 112
drwxr-xr-x 7 root root 4096 Feb 20 11:39 .
drwxr-xr-x 5 root root 4096 Feb 20 11:39 ..
drwxr-xr-x 11 root root 4096 Feb 20 11:39 bin
drwxr-xr-x 6 root root 4096 Feb 20 11:39 docs
drwxr-xr-x 7 root root 4096 Feb 20 11:39 examples
-rw-r--r-- 1 root root 32472 Apr 14 2020 LICENSE.txt
-rw-r--r-- 1 root root 3325 Jan 8 21:10 README.md
drwxr-xr-x 8 root root 4096 Feb 20 11:39 skins
drwxr-xr-x 15 root root 4096 Feb 20 11:39 util
-rw-r--r-- 1 root root 22949 Feb 20 11:39 weewx.conf
-rw-r--r-- 1 root root 22427 Feb 20 11:39 weewx.conf.4.4.0
pi@raspberrypi:~ $ sudo chown -R pi /home/weewx
pi@raspberrypi:~ $ ls -al /home/weewx
total 112
drwxr-xr-x 7 pi root 4096 Feb 20 11:39 .
drwxr-xr-x 5 root root 4096 Feb 20 11:39 ..
drwxr-xr-x 11 pi root 4096 Feb 20 11:39 bin
drwxr-xr-x 6 pi root 4096 Feb 20 11:39 docs
drwxr-xr-x 7 pi root 4096 Feb 20 11:39 examples
-rw-r--r-- 1 pi root 32472 Apr 14 2020 LICENSE.txt
-rw-r--r-- 1 pi root 3325 Jan 8 21:10 README.md
drwxr-xr-x 8 pi root 4096 Feb 20 11:39 skins
drwxr-xr-x 15 pi root 4096 Feb 20 11:39 util
-rw-r--r-- 1 pi root 22949 Feb 20 11:39 weewx.conf
-rw-r--r-- 1 pi root 22427 Feb 20 11:39 weewx.conf.4.4.0
Restore Customisations
You will most likely only be following this process if you have made customisations to your WeeWX deployment, and if that is the case you will also most likely have a process for copying those customisations into you WeeWX environment
I keep all of my customisations on my laptop in a directory structure aligned to the version of WeeWX for which they were created and then run a python script to copy these to the required destination
But regardless of the method you use there is 1 file that must be copied to your new deployment, which is the weewx.conf file. As we are running an Out-of-Place upgrade this file can be found in the save location and simply copied from there
pi@raspberrypi:~ $ ls -al /home/weewx/weewx.conf
-rw-r--r-- 1 root root 22949 Feb 18 14:48 /home/weewx/weewx.conf
pi@raspberrypi:~ $ sudo cp /home/weewx-Feb-2021/weewx.conf /home/weewx/weewx.conf
pi@raspberrypi:~ $ ls -al /home/weewx/weewx.conf
-rw-r--r-- 1 root root 22158 Feb 18 14:55 /home/weewx/weewx.conf
Restore Database
The final restore step in this process is to restore the database and again as we are running an Out-of-Place upgrade this file can be found in the save location
pi@raspberrypi:~ $ ls -al /home/weewx-Feb-2021/archive/weewx.sdb
-rw-r--r-- 1 root root 146141184 Feb 18 14:40 /home/weewx-Feb-2021/archive/weewx.sdb
pi@raspberrypi:~ $ sudo mkdir /home/weewx/archive/
pi@raspberrypi:~ $ sudo cp /home/weewx-Feb-2021/archive/weewx.sdb /home/weewx/archive/weewx.sdb
pi@raspberrypi:~ $ ls -al /home/weewx/archive/weewx.sdb
-rw-r--r-- 1 root root 146141184 Feb 18 15:00 /home/weewx/archive/weewx.sdb
Re-Start WeeWX
Once all the changes have been made it is time to restart WeeWX
pi@raspberrypi:~ $ sudo systemctl stop weewx
pi@raspberrypi:~ $ sudo systemctl status weewx
● weewx.service - weewx weather system
Loaded: loaded (/etc/systemd/system/weewx.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2021-02-18 15:10:24 UTC; 33s ago
Process: 12434 ExecStart=/home/weewx/bin/weewxd --daemon --pidfile=/var/run/weewx.pid /home/weewx/weewx.conf (code=exited, status=
Main PID: 12438 (weewxd)
Tasks: 1 (limit: 4550)
Memory: 33.7M
CGroup: /system.slice/weewx.service
└─12438 /usr/bin/python /home/weewx/bin/weewxd --daemon --pidfile=/var/run/weewx.pid /home/weewx/weewx.conf
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.restx: PWSweather: Posting not enabled.
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.restx: CWOP: Posting not enabled.
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.restx: WOW: Posting not enabled.
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.restx: AWEKAS: Posting not enabled.
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO __main__: Starting up weewx version 4.4.0
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.engine: Clock error is -0.02 seconds (positive is fast)
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.engine: Using binding 'wx_binding' to database 'weewx.sdb'
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.manager: Starting backfill of daily summaries
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.manager: Daily summaries up to date
Feb 18 15:10:24 Debian-2 weewxd[12438]: weewx[12438] INFO weewx.engine: Starting main packet loop.