From 74b15c0435b04d2213a94011d32a8ee654ef8934 Mon Sep 17 00:00:00 2001 From: Evening Date: Mon, 8 Jan 2024 13:07:59 +0800 Subject: [PATCH] Add dumping script --- src/label-studio/dump.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/label-studio/dump.sh diff --git a/src/label-studio/dump.sh b/src/label-studio/dump.sh new file mode 100644 index 00000000..d651f42e --- /dev/null +++ b/src/label-studio/dump.sh @@ -0,0 +1,16 @@ +echo "Creating backups directory..." +docker exec label-studio-db-1 sh -c "if [ ! -d \"/var/lib/postgresql/backups/\" ]; then mkdir -p \"/var/lib/postgresql/backups/\"; fi" + +echo "Checking if label-studio-db-1 is running..." +docker exec label-studio-db-1 sh -c "pg_isready -U postgres" + +if [ $? -ne 0 ]; then + echo "label-studio-db-1 is not running. Exiting..." + exit 1 +fi + +echo "Dumping database... to /var/lib/postgresql/backups/" +docker exec label-studio-db-1 sh -c "pg_dump -Fc -U postgres -d postgres -f \"/var/lib/postgresql/backups/$(date +'%d-%m-%Y_%HH%MM%SS').backup\"" + +echo "Dumping database in SQL format... to /var/lib/postgresql/backups/" +docker exec label-studio-db-1 sh -c "pg_dump -U postgres -d postgres -f \"/var/lib/postgresql/backups/$(date +'%d-%m-%Y_%HH%MM%SS').sql\""