#!/usr/bin/env python3 """One local restore on Tester 1 on the release build (R-1347/R-1348 are restore code). The household's button, privatebin (test data only, last night's copy). A marker written after the copy must be gone; the copy's files must read the same; the app answers; no hold. usage: SC= EV= TARGET=tester-1 python3 restore_tester1.py""" import os, sys, time sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts") import box_walk as w V = "/var/lib/docker/volumes/privatebin_privatebin_data/_data" LIST = f"cd {V} && find . -type f ! -name restore-marker-1103 -exec sha256sum {{}} + | sort | sha256sum | cut -c1-16; find . -type f | wc -l" w.login() print("image:", w.guest("docker ps --filter name=^/felhom-controller$ --format '{{.Image}}'").strip()) print("offered:", w.snapshots("privatebin")[:1]) print("before, files + count:", w.guest(LIST).split()) print("front door before:", w.guest("curl -sk -o /dev/null -w '%{http_code}' -H 'Host: paste.enkicsifelhom.hu' https://127.0.0.1/")) w.guest(f"date -u > {V}/restore-marker-1103; chown --reference={V} {V}/restore-marker-1103; ls {V}/restore-marker-1103") print("marker written:", w.guest(f"ls {V} | grep -c restore-marker-1103").strip()) t0 = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) rec = w.restore("privatebin") print({k: rec.get(k) for k in ("ok", "snapshot_id", "http", "location", "seconds", "state_after", "hold_after")}) time.sleep(10) print("after, files + count:", w.guest(LIST).split()) print("marker after (0 = gone):", w.guest(f"ls {V} | grep -c restore-marker-1103").strip()) print("front door after:", w.guest("curl -sk -o /dev/null -w '%{http_code}' -H 'Host: paste.enkicsifelhom.hu' https://127.0.0.1/")) st = w.stack("privatebin") print("state:", st.get("state"), "hold:", st.get("hold_reason")) print(w.guest(f"docker logs --since {t0} felhom-controller 2>&1 | grep -aiE 'restore|privatebin' | grep -av DEBUG | tail -14 | cut -c1-170 | iconv -c -t ascii//TRANSLIT")) print("ERROR lines since the press:", w.guest(f"docker logs --since {t0} felhom-controller 2>&1 | grep -c '\\[ERROR\\]'").strip()) print("container volumes after:", w.guest("docker volume ls --format '{{.Name}}' | grep -c pre-restore").strip())