19 lines
391 B
Bash
Executable File
19 lines
391 B
Bash
Executable File
#!/bin/bash
|
|
function usage() {
|
|
echo "Usage: postgres-docker-backup container_name db_user dump_file"
|
|
}
|
|
|
|
if [[ ! "$#" == 3 ]]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
container_name="$1"
|
|
db_user="$2"
|
|
dump_file="$3"
|
|
if [ -z "$container_name" ] || [ -z "$db_user" ] || [ -z "$dump_file" ]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
docker exec "$container_name" '/bin/sh' -c "pg_dumpall -U $db_user" > $dump_file
|