#50146 Issue 50145 - Add a verbose option to the backup tools
Closed 3 years ago by spichugi. Opened 5 years ago by spichugi.
spichugi/389-ds-base be_verbose_quiet  into  389-ds-base-1.3.9

@@ -13,12 +13,13 @@ 

  

  usage()

  {

-     echo "Usage: bak2db archivedir [-Z serverID] [-n backend] [-q] [-h]"

+     echo "Usage: bak2db archivedir [-Z serverID] [-n backend] [-q] [-V] [-h]"

      echo "Options:"

      echo "        archivedir   - Directory where the archived backup is located"

      echo "        -n backend   - Backend database name.  Example: userRoot"

      echo "        -Z serverID  - Server instance identifier"

      echo "        -q           - Quiet mode - suppresses output"

+     echo "        -V           - Verbose output"

      echo "        -h           - Display usage"  

  }

  
@@ -38,7 +39,7 @@ 

          ;;

  esac

  

- while getopts "hn:Z:qd:vi:a:SD:" flag

+ while getopts "hn:Z:qVd:vi:a:SD:" flag

  do

      case $flag in

          h) usage
@@ -46,6 +47,7 @@ 

          Z) servid=$OPTARG;; 

          n) args=$args" -n \"$OPTARG\"";;

          q) args=$args" -q";;

+         V) args=$args" -V";;

          d) args=$args" -d \"$OPTARG\"";;

          v) args=$args" -v";;

          D) args=$args" -D \"$OPTARG\"";;

@@ -13,11 +13,12 @@ 

  

  usage()

  {

-     echo "Usage: db2bak [archivedir] [-Z serverID] [-q] [-v] [-h]"

+     echo "Usage: db2bak [archivedir] [-Z serverID] [-q] [-V] [-v] [-h]"

      echo "Options:"

      echo "        archivedir   - Directory where the backup should be stored"

      echo "        -Z serverID  - Server instance identifier"

      echo "        -q           - Quiet mode - suppresses output"

+     echo "        -V           - Verbose output"

      echo "        -v           - Display version"

      echo "        -h           - Display usage"  

  }
@@ -36,12 +37,13 @@ 

      fi

  fi

  

- while getopts "hqd:Z:vi:a:SD" flag

+ while getopts "hqVd:Z:vi:a:SD" flag

  do

      case $flag in

          h) usage

             exit 0;;

          q) args=$args" -q";;

+         V) args=$args" -V";;

          v) args=$args" -v";;

          S) args=$args" -S";;

          D) args=$args" -D \"$OPTARG\"";;

@@ -16,7 +16,7 @@ 

  usage()

  {

      echo "Usage: db2ldif [-Z serverID] {-n backend_instance}* | {-s includesuffix}* [{-x excludesuffix}*] [-a outputfile]"

-     echo "               [-E] [-r] [-u] [-U] [-m] [-1] [-q] [-v] [-h]"

+     echo "               [-E] [-r] [-u] [-U] [-m] [-1] [-q] [-V] [-v] [-h]"

      echo "Note: either \"-n backend\" or \"-s includesuffix\" is required."

      echo "Options:"

      echo "        -Z serverID       - Server instance identifier"
@@ -31,6 +31,7 @@ 

      echo "        -m                - Do not base64 encode values"

      echo "        -1                - Do not include version text"

      echo "        -q                - Quiet mode - suppresses output"

+     echo "        -V                - Verbose output"

      echo "        -v                - Display version"

      echo "        -h                - Display usage" 

  }
@@ -99,7 +100,7 @@ 

      exit 1

  fi

  

- while getopts "hZ:vd:D:ENa:rs:x:CSut:n:UmMo1qc:" flag

+ while getopts "hZ:vd:D:ENa:rs:x:CSut:n:UmMo1qVc:" flag

  do

      case $flag in

          h) usage
@@ -125,6 +126,7 @@ 

          M) args=$args" -M";;

          1) args=$args" -1";;

          q) args=$args" -q";;        

+         V) args=$args" -V";;

          c) cwd=$OPTARG;;

          ?) usage

             exit 1;;

@@ -14,7 +14,7 @@ 

  usage()

  {

      echo "Usage: ldif2db [-Z serverID] -n backendname {-s includesuffix}* [{-x excludesuffix}*] {-i ldiffile}*"

-     echo "               [-c chunksize] [-g [string]] [-G namespace_id] [-O] [-E] [-q] [-v] [-h]"

+     echo "               [-c chunksize] [-g [string]] [-G namespace_id] [-O] [-E] [-q] [-V] [-v] [-h]"

      echo "Note: either \"-n backend\", \"-s includesuffix\", and \"-i ldiffile\" are required."

      echo "Options:"

      echo "        -Z serverID       - The server instance identifier"
@@ -31,6 +31,7 @@ 

      echo "        -O                - Do not index the attributes"

      echo "        -E                - Encrypt attributes"

      echo "        -q                - Quiet mode - suppresses output"

+     echo "        -V                - Verbose output"

      echo "        -v                - Display version"

      echo "        -h                - Display usage" 

  }
@@ -53,7 +54,7 @@ 

      return 0

  }

  

- while getopts "Z:vhd:i:g:G:n:s:x:NOCc:St:D:Eq" flag

+ while getopts "Z:vhd:i:g:G:n:s:x:NOCc:St:D:EqV" flag

  do

      case $flag in

          h) usage
@@ -76,6 +77,7 @@ 

          S) args=$args" -S";;

          O) args=$args" -O";;

          q) args=$args" -q";;

+         V) args=$args" -V";;

          ?) usage

             exit 1;;

      esac

file modified
+19 -9
@@ -94,6 +94,7 @@ 

      int upgradedb_flags;

      int upgradednformat_dryrun;

      int is_quiet;

+     int backuptools_verbose;

      int dbverify_verbose;

      char *dbverify_dbdir;

  };
@@ -1286,7 +1287,7 @@ 

       *

       */

  

-     char *opts_db2ldif = "vd:D:ENa:rs:x:CSut:n:UmMo1q";

+     char *opts_db2ldif = "vd:D:ENa:rs:x:CSut:n:UmMo1qV";

      struct opt_ext long_options_db2ldif[] = {

          {"version", ArgNone, 'v'},

          {"debug", ArgRequired, 'd'},
@@ -1306,9 +1307,10 @@ 

          {"multipleOutputFile", ArgNone, 'M'},

          {"noVersionNum", ArgNone, '1'},

          {"quiet", ArgNone, 'q'},

+         {"verbose", ArgNone, 'V'},

          {0, 0, 0}};

  

-     char *opts_ldif2db = "vd:i:g:G:n:s:x:NOCc:St:D:Eq";

+     char *opts_ldif2db = "vd:i:g:G:n:s:x:NOCc:St:D:EqV";

      struct opt_ext long_options_ldif2db[] = {

          {"version", ArgNone, 'v'},

          {"debug", ArgRequired, 'd'},
@@ -1326,9 +1328,10 @@ 

          {"configDir", ArgRequired, 'D'},

          {"encrypt", ArgOptional, 'E'},

          {"quiet", ArgNone, 'q'},

+         {"verbose", ArgNone, 'V'},

          {0, 0, 0}};

  

-     char *opts_archive2db = "vd:i:a:n:SD:q";

+     char *opts_archive2db = "vd:i:a:n:SD:qV";

      struct opt_ext long_options_archive2db[] = {

          {"version", ArgNone, 'v'},

          {"debug", ArgRequired, 'd'},
@@ -1338,10 +1341,11 @@ 

          {"allowMultipleProcesses", ArgNone, 'S'},

          {"configDir", ArgRequired, 'D'},

          {"quiet", ArgNone, 'q'},

+         {"verbose", ArgNone, 'V'},

          {0, 0, 0}};

  

  

-     char *opts_db2archive = "vd:i:a:SD:q";

+     char *opts_db2archive = "vd:i:a:SD:qV";

      struct opt_ext long_options_db2archive[] = {

          {"version", ArgNone, 'v'},

          {"debug", ArgRequired, 'd'},
@@ -1350,6 +1354,7 @@ 

          {"allowMultipleProcesses", ArgNone, 'S'},

          {"configDir", ArgRequired, 'D'},

          {"quiet", ArgNone, 'q'},

+         {"verbose", ArgNone, 'V'},

          {0, 0, 0}};

  

      char *opts_db2index = "vd:a:t:T:SD:n:s:x:";
@@ -1751,9 +1756,14 @@ 

              exit(1);

              break;

  

-         case 'V':

+         case 'V': /* verbose option for dbverify, db2ldif, ldif2db, db2bak, bak2db */

              if (mcfg->slapd_exemode == SLAPD_EXEMODE_DBVERIFY) {

                  mcfg->dbverify_verbose = 1;

+             } else if (mcfg->slapd_exemode == SLAPD_EXEMODE_LDIF2DB ||

+                 mcfg->slapd_exemode == SLAPD_EXEMODE_DB2LDIF ||

+                 mcfg->slapd_exemode == SLAPD_EXEMODE_ARCHIVE2DB ||

+                 mcfg->slapd_exemode == SLAPD_EXEMODE_DB2ARCHIVE) {

+                 mcfg->backuptools_verbose = 1;

              } else {

                  mcfg->slapd_exemode = SLAPD_EXEMODE_PRINTVERSION;

              }
@@ -2138,7 +2148,7 @@ 

                        plugin->plg_name);

          return 1;

      }

-     if (!mcfg->is_quiet) {

+     if (mcfg->backuptools_verbose) {

          slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;

      }

      if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
@@ -2261,7 +2271,7 @@ 

              return 1;

          }

  

-         if (!mcfg->is_quiet) {

+         if (mcfg->backuptools_verbose) {

              slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;

          }

          if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
@@ -2511,7 +2521,7 @@ 

          return 1;

      }

  

-     if (!mcfg->is_quiet) {

+     if (mcfg->backuptools_verbose) {

          slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;

      }

      if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
@@ -2558,7 +2568,7 @@ 

          return 1;

      }

  

-     if (!mcfg->is_quiet) {

+     if (mcfg->backuptools_verbose) {

          slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;

      }

      if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {

Bug description: RHDS 9 does not require a -q option to not log debugging messages.
-q also suppresses the output that had been included before when doing an import.

Fix description:
Make -q option less verbose by removing error log messages
and add -V option which enables Verbose DEBUG output.

https://pagure.io/389-ds-base/issue/50145

Reviewed by: ?

rebased onto 4bd9974

5 years ago

Pull-Request has been merged by spichugi

5 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3205

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago