fix(publish): use relative symlink for latest, set 0644 perms, populate rowCounts from dump
This commit is contained in:
1 parent
0bbc4ce440
commit
7116215477
3 files changed
+39
-10
No files matched your search
@@ -55,11 +55,16 @@ if [[ -f "$MEDIA_FILE" ]]; then
|
|||||||
cp -p -- "$MEDIA_FILE" "$STAGING_DIR/"
|
cp -p -- "$MEDIA_FILE" "$STAGING_DIR/"
|
||||||
fi
|
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"
|
mv -T -- "$STAGING_DIR" "$FINAL_DIR"
|
||||||
STAGING_DIR=""
|
STAGING_DIR=""
|
||||||
|
|
||||||
|
# Use relative symlink so the latest link works regardless of mount point path on different hosts
|
||||||
TEMP_LINK="$TARGET_DIR/.latest-$$"
|
TEMP_LINK="$TARGET_DIR/.latest-$$"
|
||||||
ln -s -- "$FINAL_DIR" "$TEMP_LINK"
|
ln -s -- "$TIMESTAMP" "$TEMP_LINK"
|
||||||
mv -Tf -- "$TEMP_LINK" "$TARGET_DIR/latest"
|
mv -Tf -- "$TEMP_LINK" "$TARGET_DIR/latest"
|
||||||
|
|
||||||
echo "OK: Backup-Satz veroeffentlicht unter $FINAL_DIR (latest aktualisiert)"
|
echo "OK: Backup-Satz veroeffentlicht unter $FINAL_DIR (latest aktualisiert)"
|
||||||
|
|||||||
@@ -138,21 +138,35 @@ def query_db_metadata(tcfg, dump_path):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Fallback: parse migrations from plain SQL dump if container query was unavailable
|
# Fallback: parse migrations and table row counts from plain SQL dump
|
||||||
if not migrations and detect_dump_format(dump_path) == 'plain':
|
if detect_dump_format(dump_path) == 'plain':
|
||||||
in_copy = False
|
in_copy = False
|
||||||
|
curr_table = None
|
||||||
|
tcount = 0
|
||||||
with Path(dump_path).open('r', encoding='utf-8', errors='replace') as fp:
|
with Path(dump_path).open('r', encoding='utf-8', errors='replace') as fp:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
if not in_copy:
|
if not in_copy:
|
||||||
if line.startswith('COPY public.schema_migrations ') or line.startswith('COPY schema_migrations '):
|
if line.startswith('COPY public.') or line.startswith('COPY '):
|
||||||
in_copy = True
|
parts = line.split()
|
||||||
continue
|
if len(parts) >= 2:
|
||||||
|
tbl = parts[1].replace('public.', '').replace('"', '').split('(')[0].strip()
|
||||||
|
curr_table = tbl
|
||||||
|
tcount = 0
|
||||||
|
in_copy = True
|
||||||
else:
|
else:
|
||||||
if line.startswith('\\.'):
|
if line.startswith('\\.'):
|
||||||
break
|
if curr_table:
|
||||||
parts = line.rstrip('\r\n').split('\t')
|
if not row_counts or curr_table not in row_counts:
|
||||||
if len(parts) >= 2:
|
row_counts[curr_table] = tcount
|
||||||
migrations.append(parts[1])
|
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):
|
def sort_key(stem):
|
||||||
m = re.match(r'^(\d+)', stem)
|
m = re.match(r'^(\d+)', stem)
|
||||||
|
|||||||
@@ -316,6 +316,16 @@ def main():
|
|||||||
write_result(args.result, {'status': 'error', 'exit_code': EXIT_EXEC_ERROR, 'detail': msg})
|
write_result(args.result, {'status': 'error', 'exit_code': EXIT_EXEC_ERROR, 'detail': msg})
|
||||||
return EXIT_EXEC_ERROR
|
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':
|
if args.sessions == 'clear':
|
||||||
print('5. Clearing active user sessions in staging DB (--sessions clear)...')
|
print('5. Clearing active user sessions in staging DB (--sessions clear)...')
|
||||||
psql_exec(tcfg, staging_db, 'TRUNCATE TABLE sessions;')
|
psql_exec(tcfg, staging_db, 'TRUNCATE TABLE sessions;')
|
||||||
|
|||||||
Reference in new issue
Block a user