summaryrefslogtreecommitdiffstats
path: root/ldap/admin/src/scripts
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2007-03-20 01:15:32 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2007-03-20 01:15:32 +0000
commit041f5e93d957fcbb7baaf77f220c118de8cd4668 (patch)
tree17599cf6987fceb701f5d0a72b0aeefe7357aafe /ldap/admin/src/scripts
parent3483034ff323c55dc321ae0d63e81f6d2a283e29 (diff)
downloadds-041f5e93d957fcbb7baaf77f220c118de8cd4668.tar.gz
ds-041f5e93d957fcbb7baaf77f220c118de8cd4668.tar.xz
ds-041f5e93d957fcbb7baaf77f220c118de8cd4668.zip
Resolves: #233027
Summary: make db2bak.pl & db2ldif.pl user more user-friendly (Comment #4) Changes: 1) Found db2bak, db2bak.pl, and db2ldif do not backup/export into the dir/file which do not start with the <server-id> string. It could cause the difficulty to find out which server instance does the backup/exported file belongs to. Also, to make them consistent with db2ldif.pl, added the "server id" string to the back up dir name/exported ldif file name. 2) db2ldif[.pl] takes -M option. With the -M option, the server adds backend name to the ldif file name. To reduce the redundancy, stopped adding the backend name if -M is set. 3) made the ldif file name db2ldif generates consistent with the one db2ldif.pl generates.
Diffstat (limited to 'ldap/admin/src/scripts')
-rwxr-xr-xldap/admin/src/scripts/template-db2bak.in3
-rw-r--r--ldap/admin/src/scripts/template-db2bak.pl.in2
-rwxr-xr-xldap/admin/src/scripts/template-db2ldif.in74
-rw-r--r--ldap/admin/src/scripts/template-db2ldif.pl.in6
4 files changed, 59 insertions, 26 deletions
diff --git a/ldap/admin/src/scripts/template-db2bak.in b/ldap/admin/src/scripts/template-db2bak.in
index 32e5c7a1..261919f6 100755
--- a/ldap/admin/src/scripts/template-db2bak.in
+++ b/ldap/admin/src/scripts/template-db2bak.in
@@ -17,7 +17,8 @@ if [ "$#" -eq 1 ]
then
bak_dir=$1
else
- bak_dir={{BAK-DIR}}/`date +%Y_%m_%d_%H_%M_%S`
+ bak_dir={{BAK-DIR}}/{{SERV-ID}}-`date +%Y_%m_%d_%H_%M_%S`
fi
+echo "Back up directory: $bak_dir"
./ns-slapd db2archive -D {{CONFIG-DIR}} -a $bak_dir
diff --git a/ldap/admin/src/scripts/template-db2bak.pl.in b/ldap/admin/src/scripts/template-db2bak.pl.in
index 960ed3de..54ddf49a 100644
--- a/ldap/admin/src/scripts/template-db2bak.pl.in
+++ b/ldap/admin/src/scripts/template-db2bak.pl.in
@@ -105,7 +105,7 @@ if ( $rootdn eq "" || $passwd eq "") { &usage; exit(1); }
$mn++; $yr += 1900;
$taskname = "backup_${yr}_${mn}_${dy}_${h}_${m}_${s}";
if ($archivedir eq "") {
- $archivedir = "${mybakdir}{{SEP}}${yr}_${mn}_${dy}_${h}_${m}_${s}";
+ $archivedir = "${mybakdir}{{SEP}}{{SERV-ID}}-${yr}_${mn}_${dy}_${h}_${m}_${s}";
}
$dn = "dn: cn=$taskname, cn=backup, cn=tasks, cn=config\n";
$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
diff --git a/ldap/admin/src/scripts/template-db2ldif.in b/ldap/admin/src/scripts/template-db2ldif.in
index 79d35c89..27f22bca 100755
--- a/ldap/admin/src/scripts/template-db2ldif.in
+++ b/ldap/admin/src/scripts/template-db2ldif.in
@@ -12,34 +12,62 @@ export LD_LIBRARY_PATH
SHLIB_PATH=$LD_LIBRARY_PATH
export SHLIB_PATH
+make_ldiffile()
+{
+ nobe=0
+ while [ "$1" != "" ]
+ do
+ if [ "$1" = '-a' ]; then
+ shift
+ echo $1
+ return 1
+ elif [ "$1" = '-n' ]; then
+ shift
+ if [ "$be" = "" ]; then
+ be="$1"
+ else
+ tmpbe="$be"
+ be="${tmpbe}-$1"
+ fi
+ elif [ "$1" = '-s' ]; then
+ shift
+ rdn=`echo $1 | awk -F, '{print $1}'`
+ rdnval=`echo $rdn | awk -F= '{print $2}'`
+ if [ "$be" = "" ]; then
+ be="$rdnval"
+ else
+ tmpbe="$be"
+ be="${tmpbe}-$rdnval"
+ fi
+ elif [ "$1" = '-M' ]; then
+ nobe=1
+ fi
+ shift
+ done
+
+ if [ $nobe -eq 0 ]; then
+ echo {{LDIF-DIR}}/{{SERV-ID}}-${be}-`date +%Y_%m_%d_%H%M%S`.ldif
+ else
+ echo {{LDIF-DIR}}/{{SERV-ID}}-`date +%Y_%m_%d_%H%M%S`.ldif
+ fi
+ return 0
+}
+
cd {{SERVERBIN-DIR}}
if [ "$#" -lt 2 ];
then
- echo "Usage: db2ldif {-n backend_instance}* | {-s includesuffix}*"
- echo " [{-x excludesuffix}*] [-a outputfile]"
- echo " [-N] [-r] [-C] [-u] [-U] [-m] [-M] [-1]"
- echo "Note: either \"-n backend_instance\" or \"-s includesuffix\" is required."
- exit 1
+ echo "Usage: db2ldif {-n backend_instance}* | {-s includesuffix}*"
+ echo " [{-x excludesuffix}*] [-a outputfile]"
+ echo " [-N] [-r] [-C] [-u] [-U] [-m] [-M] [-1]"
+ echo "Note: either \"-n backend_instance\" or \"-s includesuffix\" is required."
+ exit 1
fi
-set_ldif=0
-ldif_file="mydummy"
-for arg in "$@"
-do
- if [ "$arg" = '-a' ];
- then
- set_ldif=1
- elif [ $set_ldif -eq 1 ];
- then
- ldif_file=$arg
- set_ldif=2
- fi
-done
-if [ $ldif_file = "mydummy" ]
-then
- ldif_file={{LDIF-DIR}}/`date +%Y_%m_%d_%H%M%S`.ldif
-fi
-if [ $set_ldif -eq 2 ]
+ldif_file=`make_ldiffile $@`
+rn=$?
+
+echo "Exported ldif file: $ldif_file"
+if [ $rn -eq 1 ]
then
./ns-slapd db2ldif -D {{CONFIG-DIR}} "$@"
else
diff --git a/ldap/admin/src/scripts/template-db2ldif.pl.in b/ldap/admin/src/scripts/template-db2ldif.pl.in
index 3e3fa4b6..127c72fe 100644
--- a/ldap/admin/src/scripts/template-db2ldif.pl.in
+++ b/ldap/admin/src/scripts/template-db2ldif.pl.in
@@ -230,7 +230,11 @@ while ("" ne "$excluded[$i]") {
$i++;
}
if ($ldiffile eq "") {
- $ldiffile = "${ldifdir}{{SEP}}${servid}-${be}-${yr}_${mn}_${dy}_${h}_${m}_${s}.ldif";
+ if ($onefile == 0) {
+ $ldiffile = "${ldifdir}{{SEP}}${servid}-${yr}_${mn}_${dy}_${h}_${m}_${s}.ldif";
+ } else {
+ $ldiffile = "${ldifdir}{{SEP}}${servid}-${be}-${yr}_${mn}_${dy}_${h}_${m}_${s}.ldif";
+ }
}
$nsreplica = "";
if ($doreplica != 0) { $nsreplica = "nsExportReplica: true\n"; }