forked from JannikArndt/PostgreSQLSampleDatabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.sh
More file actions
executable file
·32 lines (26 loc) · 1.63 KB
/
Copy pathdump.sh
File metadata and controls
executable file
·32 lines (26 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# PostgreSQL dump script - compatibel met PostgreSQL 18
set -e
DATABASENAME=${1:-'mywebshop'}
DATA_DIR="$(dirname "$0")/data"
# Maak data directory aan indien nodig
mkdir -p "$DATA_DIR"
echo "Dumping data from database $DATABASENAME to folder $DATA_DIR/"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --schema=webshop --schema=public \
--exclude-table=webshop.products \
--exclude-table=webshop.articles \
--exclude-table=webshop.labels \
--exclude-table=webshop.customer \
--exclude-table=webshop.address \
--exclude-table=webshop.order \
--exclude-table=webshop.order_positions \
--exclude-table=webshop.stock > "$DATA_DIR/create.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.products > "$DATA_DIR/products.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.articles > "$DATA_DIR/articles.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.labels > "$DATA_DIR/labels.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.customer > "$DATA_DIR/customer.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.address > "$DATA_DIR/address.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.order > "$DATA_DIR/order.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.order_positions > "$DATA_DIR/order_positions.sql"
docker exec -it postgres pg_dump -U postgres "$DATABASENAME" --table=webshop.stock > "$DATA_DIR/stock.sql"
echo "Dump voltooid!"