You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/bash
|
|
set -x
|
|
|
|
# Uses
|
|
#
|
|
# Defauls
|
|
if [[ $# -lt 1 ]]; then
|
|
echo "Usage: pg_export container_name [database_name] [username]"
|
|
return 1
|
|
fi
|
|
|
|
CONTAINER=$1
|
|
DBNAME=${2:-aact_db}
|
|
USER=${3:-root}
|
|
|
|
#
|
|
# for sqlfile in ../export/export_data_*.sql; do
|
|
# if [[ -f "$sqlfile" ]]; then
|
|
# outfile="../export/output_$(date -I)_$(basename ${sqlfile%.sql}).sql"
|
|
# # podman exec -t "$CONTAINER" psql -U "$USER" -d "$DBNAME" -t -A -f - < "$sqlfile" > "$outfile"
|
|
# # podman exec "$CONTAINER" psql -U "$USER" -d "$DBNAME" -t -A -f "$sqlfile" > "$outfile"
|
|
# podman cp "$sqlfile" "$CONTAINER":/tmp/query.sql
|
|
# podman exec "$CONTAINER" psql -U "$USER" -d "$DBNAME" -t -A -f /tmp/query.sql > "$outfile"
|
|
# fi
|
|
# done
|
|
#
|
|
|
|
for sqlfile in ../export/export_data_*.sql; do
|
|
if [[ -f "$sqlfile" ]]; then
|
|
outfile="../export/output_$(date -I)_$(basename ${sqlfile%.sql}).sql"
|
|
podman cp "$sqlfile" "$CONTAINER":/tmp/query.sql
|
|
podman exec "$CONTAINER" psql -U "$USER" -d "$DBNAME" -f "/tmp/query.sql" > "$outfile"
|
|
fi
|
|
done
|
|
|