Skip to content

Commit ce8c468

Browse files
committed
Restore backups from a file stream
1 parent 68c3778 commit ce8c468

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Dockerfiles/Dockerfile.geocml-task-scheduler

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=linux/amd64 ubuntu:22.04
1+
FROM --platform=linux/amd64 ubuntu:latest
22

33
USER root
44
WORKDIR /

build-resources/geocml-task-scheduler/geocml-task-scheduler/tasks/restore_geocml_db_from_backups.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def restore_geocml_db_from_backups():
7373

7474
if file_name_split[0] == "data":
7575
log("Found CSV data file {}".format(csv_data_file))
76-
file_name_split = file_name_split[1].split(".")
76+
file_name_split = file_name_split[1].split(".csv")
77+
[schema, table] = [
78+
file_name_split[0].split(".")[0],
79+
file_name_split[0].split(".")[1]
80+
]
7781
csv_file_path = os.path.join(
7882
db_backups_dir, most_recent_backup, csv_data_file
7983
)
@@ -87,9 +91,10 @@ def restore_geocml_db_from_backups():
8791
with open(csv_file_path, "r") as f:
8892
# Skip the header line
8993
next(f)
90-
log("Loading data to: {}".format(file_name_split[1]))
94+
log(f"Loading data to: {schema}.{table}")
95+
cursor.execute(f'SET search_path TO {schema}')
9196
cursor.copy_from(
92-
f, f"{file_name_split[1]}", sep=",", columns=columns, null="NULL"
97+
f, table, sep=",", columns=columns, null="NULL"
9398
)
9499

95100
log("Finished loading data!")

build-resources/geocml-task-scheduler/make.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#! nix-shell -p unzip wget
44
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/tags/24.05.tar.gz
55

6-
TABOR_VERSION=0.3.0
6+
TABOR_VERSION=0.3.1
77

88
touch /task_log
99
wget "https://github.com/geoCML/tabor/releases/download/v$TABOR_VERSION/tabor-$TABOR_VERSION-ubuntu-latest.zip" -P /geocml-task-scheduler/

0 commit comments

Comments
 (0)