Backup and Maintenance
Scope: what a WeeWX station actually
stands to lose, the small set of files that
constitute its whole self, the weectl
database tools for when the summaries drift,
and the maintenance that a growing,
single-file database asks for (very little)
and rewards (a great deal).
What would be lost
Rank the losses honestly. The program is replaceable in minutes (chapter 2). The skins, as generated, are replaceable too. What cannot be regenerated is:
- The archive database — every interval since the station started. Real stations measure weather that happened once; the simulator's can be rerun, yours cannot.
weewx.conf, as edited by you — the accumulated decisions: corrections, enabled services, report tweaks. The generated original is recoverable; your years of small print are not.- Your extensions and edited skins under
bin/user/andskins/— for the same reason.
Notice what those three are: nearly the whole station directory, and not much of it is big. Check: the lab station's parts, after its first afternoon:
weewx.conf 20,945 bytes
archive/weewx.sdb 512,000 bytes (and grows by records, not leaps)
skins/ 1.9 MB (mostly fonts)
public_html/ 756 KB (regenerates; not worth backing up)
The right backup is therefore almost
embarrassingly simple: stop the engine (or
accept missing the last interval), copy the
station directory — or, at minimum, the
database file and weewx.conf with bin/
and skins/ — somewhere that is not the
same disk, on a schedule. The generated
website can be left out; it is the one part
that rebuilds itself.
The database tools
weectl database is the maintenance
workbench. Its actions, from its own help:
| Action | What it is for |
|---|---|
create |
build a fresh, empty database (and summaries) for a binding |
rebuild-daily |
reconstruct the daily summary tables from the archive records |
drop-daily |
delete the summaries so they can be rebuilt clean |
add-column |
grow the archive table when an extension brings a new stored observation |
rename |
rename an observation column |
check |
verify a database's internal consistency where the tool supports it |
The pair you will actually reach for is
drop-daily followed by rebuild-daily
(with the engine stopped, and a copy of the
file taken first — the tools offer
--dry-run and ask for confirmation, and
the courtesy is worth honouring). The
occasions are the ones chapter 6 named: the
summaries are a cache, and caches
occasionally need rebuilding after a crash
mid-write, a restore from an old copy, or a
configuration change to what gets
calculated. The archive records are never
the thing being repaired; they are what the
repair is built from.
The engine also does quiet maintenance of its own: the startup backfill of chapter 6 resumes the summaries from wherever they stopped, which is most of why a WeeWX station survives power cuts with nothing worse than a gap.
Living with growth
A SQLite archive asks for almost nothing: no vacuuming schedule worth the name, no index tuning, no server to patch. Three habits cover a decade:
- Watch the disk, not the database. The failure mode is a full card on a Pi, and it takes the system down, not just the weather. The database's slow, linear growth is the easiest part of that arithmetic.
- Keep the clock honest. Chapter 5's clock check is maintenance too: a station whose clock drifts writes records into the wrong intervals, and no rebuild repairs timestamps that were wrong when written.
- Upgrade the program in daylight. A new WeeWX version may migrate the database schema on first run. That is routine and announced in its release notes — and it is why the backup above is taken before the upgrade, not after the surprise.
Retiring, moving, and the long view
Moving a station is moving its directory: install the program on the new machine, create or copy the station data across, start the engine, and the weather continues — the database's history does not care which computer reads it. Retiring one is the same minus the starting: the database file, kept, remains readable by any future WeeWX (and by any SQLite tool) indefinitely. A station's decade of Novembers fits on the smallest storage you own. Keep two copies of it anyway. That is the whole sermon.