From 43c99854e237f1507cf0c39824f235bf51eb6125 Mon Sep 17 00:00:00 2001 From: tanneberger Date: Mon, 30 Dec 2024 00:01:22 +0100 Subject: [PATCH] workaround for postgres has problems writing to the tmpfile --- modules/data-hoarder/postgres.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/data-hoarder/postgres.nix b/modules/data-hoarder/postgres.nix index 3c0012e..102d6cc 100644 --- a/modules/data-hoarder/postgres.nix +++ b/modules/data-hoarder/postgres.nix @@ -64,7 +64,7 @@ OUT_FOLDER=/var/lib/pub-files/postgres-dumps/$(date -d"$(date) - 1 day" +"%Y-%m") CSV_FILENAME=$(date -d"$(date) - 1 day" +"%Y-%m-%d").csv - psql -d tlms -c "COPY (SELECT id, to_char(time::timestamp at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS') time, station, r09_type, delay, reporting_point, junction, direction, request_status, priority, direction_request, line, run_number, destination_number, train_length, vehicle_number, operator, region FROM r09_telegrams WHERE time > now() - interval '24 hours' ORDER by time ASC) TO '$TMPFILE' DELIMITER ',' HEADER CSV;" + psql -d tlms -c "COPY (SELECT id, to_char(time::timestamp at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS') time, station, r09_type, delay, reporting_point, junction, direction, request_status, priority, direction_request, line, run_number, destination_number, train_length, vehicle_number, operator, region FROM r09_telegrams WHERE time > now() - interval '24 hours' ORDER by time ASC) TO STDOUT DELIMITER ',' HEADER CSV;" > $TMPFILE mkdir -p $OUT_FOLDER chmod a+xr $OUT_FOLDER