root/packages/fuss-server/back_ldap @ 9648c5e55186086a5451a2624d3efa05261b2953

Revision 9648c5e55186086a5451a2624d3efa05261b2953, 1.5 KB (checked in by Enrico Zini <enrico@…>, 4 years ago)

Moved etch packages in etch branch

  • Property mode set to 100755
Line 
1#!/bin/sh
2# /etc/cron.daily/standard: standard daily maintenance script
3# Written by Ian A. Murdock <imurdock@gnu.ai.mit.edu>
4# Modified by Ian Jackson <ijackson@nyx.cs.du.edu>
5# Modified by Steve Greenland <stevegr@debian.org>
6# Modified by Simone Piccardi <piccardi@trelite.it> for LDAP backup
7
8
9bak=/var/backups
10LOCKFILE=/var/lock/cron.daily
11umask 022
12
13#
14# Avoid running more than one at a time -- could happen if the
15# checksecurity script lands on a network drive.
16#
17
18if [ -x /usr/bin/lockfile-create ] ; then
19    lockfile-create $LOCKFILE
20    if [ $? -ne 0 ] ; then
21        cat <<EOF
22
23Unable to run /etc/cron.daily/back_ldap because lockfile $LOCKFILE
24acquisition failed. This probably means that the previous days
25instance is still running. Please check and correct if necessary.
26
27EOF
28        exit 1
29    fi
30
31    # Keep lockfile fresh
32    lockfile-touch $LOCKFILE &
33    LOCKTOUCHPID="$!"
34fi
35
36#
37# Backup LDAP database
38#
39
40OLDBACK=slapd_back_`date +%F -d"8 days ago"`
41if cd $bak ; then
42    # do the backup if the daemon is running
43    if [ -f /var/run/slapd/slapd.pid ]; then
44        /etc/init.d/slapd stop
45        # dump data with slapcat
46        slapcat >  back_`date +%F`
47        # restart the daemon
48        /etc/init.d/slapd start
49        # remove old backups
50        [ -f "$OLDBACK" ] && rm  back_`date +%F -d"8 days ago"`
51        # remove old log file
52        cd /var/lib/ldap
53        db4.2_archive -d
54    fi
55fi
56
57#
58# Clean up lockfile
59#
60if [ -x /usr/bin/lockfile-create ] ; then
61    kill $LOCKTOUCHPID
62    lockfile-remove $LOCKFILE
63fi
Note: See TracBrowser for help on using the browser.