# * Add crontab job for root user (or whatever user you want):
#
# # crontab -e -u postgres
-# 1 4 * * * bash /path/to/backup_pgsql.sh
+# 1 4 * * * bash /path/to/backup_pgsql.sh -q
#
# * Make sure 'crond' service is running.
#
DEBUG="n"
QUIET='n'
-VERSION="2.3"
+VERSION="3.1"
# console colors:
RED=""
Options:
-K|--keep DAYS Keep the backup files of the last DAYS. Default: ${KEEP_DAYS} days.
- -b|--backupdir DIR Set backup directory. Sets backup rootdir to the same. Default today: ${BACKUP_DIR}
+ -b|--backupdir DIR
+ Set root backup directory. Default: ${BACKUP_ROOTDIR}
-d|--debug Debug output (bash -x).
-v|--verbose Set verbosity on. Mutually exclusive to '--quiet'.
-q|--quiet Quiet execution, only errors and warnings are shown.
local base_dir=
set +e
- tmp=$( getopt -o K:dvqhV \
- --long keep:,debug,verbose,quiet,nocolor,help,version \
+ tmp=$( getopt -o K:b:dvqhV \
+ --long keep:,backupdir:,debug,verbose,quiet,nocolor,help,version \
-n "${BASENAME}" -- "$@" )
if [[ $? != 0 ]] ; then
echo "" >&2
shift
;;
-b|--backupdir)
- BACKUP_DIR="$2"
BACKUP_ROOTDIR="$2"
+ BACKUP_DIR="${BACKUP_ROOTDIR}/${YEAR}/${MONTH}/${DAY}"
shift
shift
;;