diff --git a/pg_db_dump_file.sh b/pg_db_dump_file.sh index bc040ee..348c7bb 100755 --- a/pg_db_dump_file.sh +++ b/pg_db_dump_file.sh @@ -57,7 +57,7 @@ LOG_PATH=''; # base path for PostgreSQL binary # DBPATH_BASE=''; # defaults -_BACKUPDIR='/mnt/backup/db_dumps_fc/'; +_BACKUPDIR=''; _DB_VERSION=$( pgv=$( pg_dump --version | grep "pg_dump" | cut -d " " -f 3 @@ -324,11 +324,10 @@ if [ ! -f "${PG_PSQL}" ] || [ ! -f "${PG_DUMP}" ] || [ ! -f "${PG_DUMPALL}" ]; t exit 0; fi; -if [ ! -d "${BACKUPDIR}" ] ; then - if ! mkdir "${BACKUPDIR}" ; then - echo "Cannot create backup directory: ${BACKUPDIR}" - exit 0; - fi +# not directory or length is zero +if [ ! -d "${BACKUPDIR}" ] || [ -z "${BACKUPDIR}" ]; then + echo "Backup directory does not exist: ${BACKUPDIR}"; + exit 0; fi # check if we can write into that folder touch "${BACKUPDIR}/tmpfile" || echo "[!] touch failed"; @@ -336,7 +335,7 @@ if [ ! -f "${BACKUPDIR}/tmpfile" ]; then echo "Cannot write to ${BACKUPDIR}"; exit 0; else - rm -f "${BACKUPDIR}/tmpfile"; + rm "${BACKUPDIR}/tmpfile"; fi; # if backupdir is "." rewrite to pwd if [ "${BACKUPDIR}" == '.' ]; then