]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Bugfixing and version bump of bin/backup_pgsql.sh
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 22 May 2019 13:38:02 +0000 (15:38 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 22 May 2019 13:38:02 +0000 (15:38 +0200)
bin/backup_pgsql.sh

index 1c778cea7d46b2eb818d72af55fac86c5b72eb74..195ae0ff6ac6ae458b140551bee4e2935e394cc2 100755 (executable)
@@ -27,7 +27,7 @@
 #   * 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.
 #
@@ -42,7 +42,7 @@ VERBOSE="n"
 DEBUG="n"
 QUIET='n'
 
-VERSION="2.3"
+VERSION="3.1"
 
 # console colors:
 RED=""
@@ -151,7 +151,8 @@ usage() {
 
            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.
@@ -169,8 +170,8 @@ get_options() {
     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
@@ -192,8 +193,8 @@ get_options() {
                 shift
                 ;;
             -b|--backupdir)
-                BACKUP_DIR="$2"
                 BACKUP_ROOTDIR="$2"
+                BACKUP_DIR="${BACKUP_ROOTDIR}/${YEAR}/${MONTH}/${DAY}"
                 shift
                 shift
                 ;;