~ubuntu-branches/ubuntu/trusty/389-ds-base/trusty

« back to all changes in this revision

Viewing changes to ldap/admin/src/scripts/db2bak.in

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2013-08-30 00:31:55 UTC
  • mfrom: (1.2.1)
  • Revision ID: package-import@ubuntu.com-20130830003155-oimuzdqopkvp2cd0
Tags: 1.3.1.7-0ubuntu1
Sync from unreleased debian git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
source @datadir@/@package_name@/data/DSSharedLib
 
4
 
 
5
libpath_add "@libdir@/@package_name@/"
 
6
libpath_add "@nss_libdir@"
 
7
libpath_add "@libdir@"
 
8
libpath_add "@pcre_libdir@"
 
9
 
 
10
export LD_LIBRARY_PATH
 
11
SHLIB_PATH=$LD_LIBRARY_PATH
 
12
export SHLIB_PATH
 
13
 
 
14
usage()
 
15
{
 
16
    echo "Usage: db2bak [archivedir] [-Z serverID] [-q] [-h]"
 
17
    echo "Options:"
 
18
    echo "        archivedir   - Directory where the backup should be stored"
 
19
    echo "        -Z serverID  - Server instance identifier"
 
20
    echo "        -q           - Quiet mode - suppresses output"
 
21
    echo "        -h           - Display usage"  
 
22
}
 
23
 
 
24
if [ $# -gt 4 ]
 
25
then
 
26
    usage
 
27
    exit 1
 
28
fi
 
29
 
 
30
if [ "$#" -gt 0 ]
 
31
then
 
32
    if [[ $1 != -* ]]
 
33
    then
 
34
        bak_dir=$1
 
35
        shift
 
36
    fi
 
37
fi
 
38
 
 
39
while getopts "hqd:Z:vi:a:SD" flag
 
40
do
 
41
    case $flag in
 
42
        h) usage
 
43
           exit 0;;
 
44
        q) args=$args" -q";;
 
45
        v) args=$args" -v";;
 
46
        S) args=$args" -S";;
 
47
        D) args=$args" -D $OPTARG";;
 
48
        i) args=$args" -i $OPTARG";;
 
49
        a) $bakdir=$OPTARG;;
 
50
        d) args=$args" -d $OPTARG";;
 
51
        Z) servid=$OPTARG;;
 
52
        ?) usage
 
53
           exit 1;;
 
54
    esac
 
55
done
 
56
 
 
57
 
 
58
initfile=$(get_init_file "@initconfigdir@" $servid)
 
59
if [ $? == 1 ]
 
60
then
 
61
    usage
 
62
    echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
 
63
    echo "Available instances: $initfile"
 
64
    exit 1
 
65
fi
 
66
 
 
67
servid=`normalize_server_id $initfile`
 
68
. $initfile
 
69
 
 
70
if [ -z $bak_dir ]
 
71
then
 
72
    bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S`
 
73
fi
 
74
 
 
75
echo "Back up directory: $bak_dir"
 
76
@sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args