Skip to content

Commit

Permalink
Add dumping script
Browse files Browse the repository at this point in the history
  • Loading branch information
Eve-ning committed Jan 8, 2024
1 parent 53d38e5 commit 74b15c0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/label-studio/dump.sh
Original file line number Diff line number Diff line change
@@ -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\""

0 comments on commit 74b15c0

Please sign in to comment.