#!/bin/bash

echo "Export data"

docker compose exec -ti postgres su postgres -c 'pg_dump -d postgres -U postgres -n rtls_pu \
--exclude-table-data=rtls_pu.rtls_mileage \
--exclude-table-data=rtls_pu.rtls_tag_sensor \
--exclude-table-data=rtls_pu.rtls_event \
--exclude-table-data=rtls_pu.rtls_area_event \
-Fc -f /var/lib/postgresql/data/schema.dmp'

if [ ! -f postgres/schema.dmp ]; then
    echo "Export failed"
    exit 1
fi
