Skip to content

v5.2.1 - Restore Script & Backup Improvements

Latest

Choose a tag to compare

@jasonacox-sam jasonacox-sam released this 08 Aug 23:36
· 1 commit to main since this release
b1c5732

v5.2.1 - Restore Script & Backup Improvements

New Features

  • Restore script — new backups/restore.sh.sample, an automated companion to backup.sh.sample, based on restore_v16a.sh by @JonMurphy (#836). One command restores a backup archive on the same machine or migrates to a new one:

    • Auto-detects the Powerwall-Dashboard directory from the script's own location
    • Checks staging disk space before extracting (warns and offers TMPDIR override — protects RAM-backed /tmp from multi-GB archives)
    • Non-destructive — moves existing InfluxDB data/meta/wal and grafana.db aside as .pre-restore.<timestamp> copies (rollback path) instead of deleting
    • Restores InfluxDB from the influxd backup -portable snapshot into a clean instance, then re-creates continuous queries from the archive's continuous_queries.txt (live CQ state, including customizations) with influxdb.sql as fallback — influxd restore -portable does not reliably restore CQs (known InfluxDB 1.x limitation). CQ replay output is checked for errors (the influx CLI exits 0 even on failed statements).
    • Restores Grafana database and provisioning files with correct ownership, deriving PWD_USER as the invoking user's uid:gid (SUDO_UID:SUDO_GID) — the same convention setup.sh uses — with a guard against running from a root shell
    • Restores user configuration files (*.env, telegraf.local, etc.) while skipping git-managed project files (powerwall.yml, telegraf.conf, influxdb.conf, VERSION) so an older backup can never downgrade the stack or break future git pull/upgrades
    • Restores weather/weather411.conf and .auth/ Tesla cloud tokens (when present in the archive), so cross-machine migrations keep weather and cloud-mode credentials without re-authenticating
    • Finishes with compose-dash.sh up -d so containers are recreated and restored settings (including the rewritten PWD_USER) actually take effect
  • Backup script improvementsbackup.sh.sample now auto-detects the dashboard directory (no more editing DASHBOARD= by hand), verifies the influxdb container is running and checks dashboard-disk free space before taking the snapshot, exports live continuous queries into the archive as a safety net, captures weather/weather411.conf and .auth/ tokens, checks the exit code of influxd backup (no more silently archiving a failed snapshot), verifies archive integrity after creation, creates archives with mode 600 (they contain credentials), and aborts with a clear message if the staging area can't hold the snapshot (with TMPDIR override).

  • tesla-history --dry-run and --version — new --dry-run option to preview API actions without making calls, and --version flag to print the build number. (PR #841)

Bug Fixes

  • weather411 timestamp deprecation — replaced deprecated datetime.utcfromtimestamp() calls (scheduled for removal in Python 3.12+) with the documented equivalent. (PR #839 by @youzer-name)
  • Ctrl-C during backup/restore — SIGINT now exits cleanly instead of continuing with partial data.
  • CQ restore reliability — continuous query replay now detects failures (the influx 1.x CLI exits 0 even on statement errors), normalizes semicolons for batch parsing, and falls back to influxdb.sql when archive replay reports errors.

Documentation

  • backups/README.md — documents the restore script as the recommended method; manual restore steps retained as a fallback and corrected to exclude git-managed files and use compose-dash.sh up -d.
  • tools/DOCKER.md — replaced newgrp with clearer log out/in instructions for the docker group. (PR #837)

Files Changed

  • backups/restore.sh.samplenew — companion restore script
  • backups/backup.sh.sample — rewritten with auto-detect, pre-flight checks, weather/.auth coverage, archive verification
  • backups/README.md — restore documentation
  • weather/server.py — timestamp deprecation fix
  • tools/tesla-history/tesla-history.py — --dry-run, --version, build numbers
  • tools/weather-history/weather-history.py — --dry-run, --version, build numbers
  • tools/tesla-history/README.md, tools/weather-history/README.md — documentation updates
  • tools/DOCKER.md — docker group instructions
  • VERSION5.2.05.2.1
  • upgrade.sh — version consistency

Contributors

Thanks to the community members who made this release possible:

  • @JonMurphy — wrote the original restore_v16a.sh, tested every iteration cross-machine (RPi5 → Dell OptiPlex), caught the CQ format mismatch, missing semicolons, SUDO_UID derivation, Ctrl-C trap, disk-space ordering, config glob simplification, and the compression time UX issue. Every real bug in the restore script was found by Jon on real hardware. (#836, PR #838)
  • @hulkster — feedback on filename timestamp collisions, compression time UX, and chmod 600 copy friction that shaped the final design. (PR #838)
  • @mcbirse — tesla-history improvements: --version option, build numbers, --dry-run option refinements, and not counting standard API calls as paid usage. (PR #841)
  • @youzer-name — weather411 datetime.utcfromtimestamp() deprecation fix. (PR #839)

Links