fix(publish): use relative symlink for latest, set 0644 perms, populate rowCounts from dump

This commit is contained in:
Lars committed 2026-10-29 16:02:37 +01:00
1 parent 0bbc4ce440
commit 7116215477
3 files changed
+39 -10

No files matched your search

+6 -1
View File
@@ -55,11 +55,16 @@ if [[ -f "$MEDIA_FILE" ]]; then
cp -p -- "$MEDIA_FILE" "$STAGING_DIR/"
fi
# Ensure all backup artifacts are readable across hosts (e.g. llmadmin on llm-node)
chmod 0755 "$STAGING_DIR"
chmod 0644 "$STAGING_DIR"/*
mv -T -- "$STAGING_DIR" "$FINAL_DIR"
STAGING_DIR=""
# Use relative symlink so the latest link works regardless of mount point path on different hosts
TEMP_LINK="$TARGET_DIR/.latest-$$"
ln -s -- "$FINAL_DIR" "$TEMP_LINK"
ln -s -- "$TIMESTAMP" "$TEMP_LINK"
mv -Tf -- "$TEMP_LINK" "$TARGET_DIR/latest"
echo "OK: Backup-Satz veroeffentlicht unter $FINAL_DIR (latest aktualisiert)"
+23 -9
View File
@@ -138,21 +138,35 @@ def query_db_metadata(tcfg, dump_path):
except Exception:
pass
# Fallback: parse migrations from plain SQL dump if container query was unavailable
if not migrations and detect_dump_format(dump_path) == 'plain':
# Fallback: parse migrations and table row counts from plain SQL dump
if detect_dump_format(dump_path) == 'plain':
in_copy = False
curr_table = None
tcount = 0
with Path(dump_path).open('r', encoding='utf-8', errors='replace') as fp:
for line in fp:
if not in_copy:
if line.startswith('COPY public.schema_migrations ') or line.startswith('COPY schema_migrations '):
in_copy = True
continue
if line.startswith('COPY public.') or line.startswith('COPY '):
parts = line.split()
if len(parts) >= 2:
tbl = parts[1].replace('public.', '').replace('"', '').split('(')[0].strip()
curr_table = tbl
tcount = 0
in_copy = True
else:
if line.startswith('\\.'):
break
parts = line.rstrip('\r\n').split('\t')
if len(parts) >= 2:
migrations.append(parts[1])
if curr_table:
if not row_counts or curr_table not in row_counts:
row_counts[curr_table] = tcount
in_copy = False
curr_table = None
tcount = 0
else:
tcount += 1
if curr_table == 'schema_migrations' and not migrations:
parts = line.rstrip('\r\n').split('\t')
if len(parts) >= 2:
migrations.append(parts[1])
def sort_key(stem):
m = re.match(r'^(\d+)', stem)
+10
View File
@@ -316,6 +316,16 @@ def main():
write_result(args.result, {'status': 'error', 'exit_code': EXIT_EXEC_ERROR, 'detail': msg})
return EXIT_EXEC_ERROR
# Verify active media_assets count in staging database
act_res = psql_exec(tcfg, staging_db, "SELECT COUNT(*)::int FROM media_assets WHERE lifecycle_state = 'active';")
if act_res.returncode == 0 and act_res.stdout.strip().isdigit():
act_cnt = int(act_res.stdout.strip())
if act_cnt < 1:
drop_db_if_exists(tcfg, staging_db)
msg = f'Plausibility check failed: expected active media_assets, found {act_cnt}'
write_result(args.result, {'status': 'error', 'exit_code': EXIT_EXEC_ERROR, 'detail': msg})
return EXIT_EXEC_ERROR
if args.sessions == 'clear':
print('5. Clearing active user sessions in staging DB (--sessions clear)...')
psql_exec(tcfg, staging_db, 'TRUNCATE TABLE sessions;')