Created
November 20, 2019 22:10
-
-
Save twopoint718/e22fe1298966f1c809f49d4a2c5ca5bb to your computer and use it in GitHub Desktop.
Script that returns all on-disk PostgreSQL database files for a given database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/bash | |
| set -e | |
| if [ -z "$1" ]; then | |
| echo "Must provide database name, e.g. 'my_database'" | |
| exit 1 | |
| fi | |
| db_dir=$(psql postgres -Atc "select (select setting from pg_settings where name = 'data_directory') || '/base/' || (select oid from pg_database where datname='$1')") | |
| find "${db_dir}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment