File: db2bak.in

package info (click to toggle)
389-ds-base 1.4.0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 50,776 kB
  • sloc: ansic: 303,582; python: 59,673; cpp: 10,380; perl: 5,807; sh: 2,654; makefile: 2,457; yacc: 806; xml: 376; lex: 366; java: 50
file content (85 lines) | stat: -rwxr-xr-x 1,910 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash

. @datadir@/@package_name@/data/DSSharedLib

libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
libpath_add "@libdir@"
libpath_add "@pcre_libdir@"

export LD_LIBRARY_PATH
SHLIB_PATH=$LD_LIBRARY_PATH
export SHLIB_PATH

usage()
{
    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"  
}

if [ $# -gt 4 ]
then
    usage
    exit 1
fi
if [ "$#" -gt 0 ]
then
    if [[ $1 != -* ]]
    then
        bak_dir=$1
        shift
    fi
fi

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\"";;
        i) args=$args" -i \"$OPTARG\"";;
        a) $bakdir=$OPTARG;;
        d) args=$args" -d \"$OPTARG\"";;
        Z) servid=$OPTARG;;
        ?) usage
           exit 1;;
    esac
done

shift $(($OPTIND - 1))
if [ $1 ]
then
    echo "ERROR - Unknown option: $1"
    usage
    exit 1
fi

initfile=$(get_init_file "@initconfigdir@" $servid)
if [ $? -eq 1 ]
then
    usage
    echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
    echo "Available instances: $initfile"
    exit 1
fi

servid=`normalize_server_id $initfile`
. $initfile

if [ -z "$bak_dir" ]
then
    bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S`
fi

echo "Back up directory: $bak_dir"
eval @sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args