aboutsummaryrefslogtreecommitdiffstats
path: root/mayor-orig/mayor-naplo/bin/sbin/eNaploBackup.sh
blob: 5bdba1772d928e91f12d7e490994c3722e432566 (plain)
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
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
##
# Az elektronikus mentése (Version 1.0)
##

    DATE=`date +%Y%m%d`
    NAPLO_BACKUP_BASE_DIR='/backup/naplo'
    NAPLO_BACKUP_DIR="$NAPLO_BACKUP_BASE_DIR/$DATE"

    DATABASES='mayor_parent mayor_private mayor_naplo intezmeny_fasori naplo_fasori_2007'
    #MYSQL_DB='%MYSQL_NAPLO_DB%'
    MYSQL_USER='%MYSQL_NAPLO_USER%'
    MYSQL_PW='%MYSQL_NAPLO_PW%'

    WWW_SSL_DIR='%BASEDIR%'
    WEB_SERVER_USER='%WEB_SERVER_USER%'
    EXPIRE_DATE=`date -d '30 days ago' +%Y%m%d`

    BASEDN='%BASEDN%'
    LDAP_CONF_DIR='%LDAP_CONF_DIR%'
    LDAP_DB_DIR='%LDAP_DB_DIR%'

##
# A könyvtárak létrehozása
##
    if [ ! -e  $NAPLO_BACKUP_BASE_DIR ]; then
	/bin/mkdir $NAPLO_BACKUP_BASE_DIR
    fi
    /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_BASE_DIR
    /bin/chmod 700 $NAPLO_BACKUP_BASE_DIR

    if [ -e $NAPLO_BACKUP_DIR.tgz ]; then
	exit 1
    fi
    /bin/mkdir $NAPLO_BACKUP_DIR
    /bin/chown $WEB_SERVER_USER $NAPLO_BACKUP_DIR
    /bin/chmod 700 $NAPLO_BACKUP_DIR

##
# mysql adatbázis mentése
##

for DATABASE in $DATABASES; do
    /usr/bin/mysqldump -p$MYSQL_PW -u$MYSQL_USER $DATABASE >> $NAPLO_BACKUP_DIR/$DATABASE.sql
done

##
# mysql adatbázis mentése
##

#    /usr/bin/mysqldump -p$MYSQL_PW -u$MYSQL_USER $MYSQL_DB >> $NAPLO_BACKUP_DIR/$MYSQL_DB.sql

##
# A honlap mentése
##

    mkdir $NAPLO_BACKUP_DIR/html

    /bin/cp -a $WWW_SSL_DIR/* $NAPLO_BACKUP_DIR/html/

##
# Az LDAP adatbázis
##

    /etc/init.d/slapd stop
    /bin/sleep 1

    /usr/sbin/slapcat -b $BASEDN -l $NAPLO_BACKUP_DIR/ldap.ldif

    /bin/cp -a $LDAP_DB_DIR $NAPLO_BACKUP_DIR/ldap

    /etc/init.d/slapd start

##
# LDAP konfig file-ok mentése (schema)
##

    /bin/mkdir $NAPLO_BACKUP_DIR/etc
    /bin/cp -a  $LDAP_CONF_DIR $NAPLO_BACKUP_DIR/etc/

##
# Becsomagolás
##

    cd $NAPLO_BACKUP_BASE_DIR
    /bin/tar cfz $DATE.tgz $DATE
    /bin/rm -rf $NAPLO_BACKUP_DIR

##
# Elavult mentés tölése
##

    if [ -e $NAPLO_BACKUP_BASE_DIR/$EXPIRE_DATE.tgz ]; then
        rm -rf $NAPLO_BACKUP_BASE_DIR/$EXPIRE_DATE.tgz
    fi