diff --git a/ops/restore-tests/common.sh b/ops/restore-tests/common.sh index 594dfd8..2baf43d 100644 --- a/ops/restore-tests/common.sh +++ b/ops/restore-tests/common.sh @@ -25,7 +25,7 @@ latest_archive_name() { import sqlite3 conn = sqlite3.connect('/data/borg.db') cur = conn.cursor() -cur.execute("select archive_name from backup_jobs where status='completed' order by created_at desc limit 1") +cur.execute("select archive_name from backup_jobs where status in ('completed', 'completed_with_warnings') order by created_at desc limit 1") row = cur.fetchone() if not row: raise SystemExit("No completed borg archive found") @@ -59,10 +59,16 @@ conn = sqlite3.connect('/data/borg.db') cur = conn.cursor() cur.execute("select path from repositories where path is not null and path != '' order by id asc limit 1") repo = cur.fetchone()[0] -cur.execute("select archive_name from backup_jobs where status='completed' order by created_at desc limit 1") +cur.execute("select archive_name from backup_jobs where status in ('completed', 'completed_with_warnings') order by created_at desc limit 1") archive = cur.fetchone()[0] with open('/local/secrets/borg_repo_passphrase.txt', 'r', encoding='utf-8') as f: os.environ['BORG_PASSPHRASE'] = f.read().strip() +known_hosts = '/data/known_hosts' +if os.path.exists(known_hosts): + os.environ.setdefault( + 'BORG_RSH', + f'ssh -o UserKnownHostsFile={known_hosts} -o StrictHostKeyChecking=yes', + ) os.makedirs(extract_dir, exist_ok=True) os.chdir(extract_dir) subprocess.run(['borg', 'extract', f'{repo}::{archive}', *paths], check=True)