Koozali.org: home of the SME Server

Restore OX Funktioniert !

Offline yythoss

  • *
  • 532
  • +0/-0
    • http://www.hylafax-client.de
Restore OX Funktioniert !
« Reply #15 on: January 05, 2007, 09:59:10 AM »
Im Outlook habe ich ganu das gleiche Problem und würde mich freuen wenn Du eine Lösung hast. So benutze ich z.B. mein Handy für Termin, Aufgaben und Kontakte, die ich dann mit Outlook synchronisiere.
Diese neuen Daten werden mit OXtender auch nicht gepushed.

Bei mir besteht das Problem mit dem OXtender immer nach dem restore_ox und meldet, Error 500, es wurden die Folders nicht gefunden.

Ich habe jetzt schon mit pg_dumpall Versuche gemacht, welche aber auch nicht zum Erfolg geführt haben. Ich weis nun bald nicht mehr was mein Problem sein soll. Die Rechte der DB können es ja wohl nicht sein.

Hallo Fraunhofer, welches restore_ox  und backup_ox verwendest Du und welches Szenario wendest Du zum Backup und Restore an, so dass Dein OXtender weiterhin funktioniert?

yythoss

Offline yythoss

  • *
  • 532
  • +0/-0
    • http://www.hylafax-client.de
Restore OX Funktioniert !
« Reply #16 on: January 05, 2007, 03:37:36 PM »
Es hat sich nun gezeigt, dass das restore_ox im Grunde OK war, jedoch die einzelnen Dienste in der richtigen Reihenfolge neu gestartet werden müssen. Ich habe nun das restore_ox entsprechend erweitert.

Hier nun noch mal alle Scripts die gebraucht werden.

/usr/local/open-xchange/sbin/backup_ox

Code: [Select]
#!/bin/bash
#
# by vincent Filali-ansary filali.v@free.fr
#

PATH=/usr/local/sbin:$PATH
export PATH


function OXbackup() {
DOM=`/sbin/e-smith/db configuration get DomainName`

service ldap restart 2>&1 >/dev/null
cp -f /home/e-smith/db/ldap/${DOM}.ldif /home/e-smith/db/ldap/${DOM}.ldif.bak

[ ! -d /home/e-smith/db/pgsql ] && mkdir /home/e-smith/db/pgsql
su postgres -c'pg_dump -Fc -b openexchange -v' > /home/e-smith/db/pgsql/ox_${DOM}.sql
#su postgres -c'pg_dumpall -v' > /home/e-smith/db/pgsql/ox_${DOM}.sql
#pg_dumpall -v -c -D -U postgres > /home/e-smith/db/pgsql/ox_thossx.de.sql
 
[ ! -d /home/e-smith/open-xchange ] && mkdir /home/e-smith/open-xchange
/usr/bin/rsync -aur --delete /usr/local/open-xchange/var /home/e-smith/open-xchange
}

function OXbackupHa() {
DOM=`/sbin/e-smith/db configuration get DomainName`

service ldap restart 2>&1 >/dev/null
cp -f /home/e-smith/db/ldap/${DOM}.ldif /home/e-smith/db/ldap/${DOM}.ldif.bak
[ ! -d /home/e-smith/files/db/ldap ] && mkdir -p /home/e-smith/files/db/ldap
cp -f /home/e-smith/db/ldap/${DOM}.ldif /home/e-smith/files/db/ldap/${DOM}.ldif
cp -f /home/e-smith/db/ldap/${DOM}.ldif /home/e-smith/files/db/ldap/${DOM}.ldif.bak

[ ! -d /home/e-smith/db/pgsql ] && mkdir /home/e-smith/db/pgsql
su postgres -c'pg_dump -Fc -b openexchange -v' > /home/e-smith/db/pgsql/ox_${DOM}.sql
[ ! -d /home/e-smith/files/db/pgsql ] && mkdir -p /home/e-smith/files/db/pgsql
su postgres -c'pg_dump -Fc -b openexchange -v' > /home/e-smith/files/db/pgsql/ox_${DOM}.sql

[ ! -d /home/e-smith/open-xchange ] && mkdir /home/e-smith/open-xchange
/usr/bin/rsync -aur --delete /usr/local/open-xchange/var /home/e-smith/open-xchange

[ ! -d /home/e-smith/files/saves/open-xchange ] && mkdir -p /home/e-smith/files/saves/open-xchange
/usr/bin/rsync -aur --delete /usr/local/open-xchange/var /home/e-smith/files/saves/open-xchange
}

# check for heartbeat system
if [ -x /usr/local/sbin/getnode ]; then
MYNODE=`getnode`
HERIP=`getnode --mirror --ip`
HERNAME=`getnode --mirror`
# first thing verify if whe are the active node
ACTIV=`/sbin/e-smith/db heartbeat getprop nodes Active`

if [ $MYNODE == $ACTIV ]; then
OXbackupHa
fi
else
OXbackup
fi


/usr/local/open-xchange/sbin/restore_ox

Code: [Select]
#!/bin/bash

PATH=/usr/local/sbin:$PATH
export PATH

function StopServices() {
#########################################################################
service open-xchange stop 2>&1 >/dev/null
service postgresql stop 2>&1 >/dev/null
service ldap stop 2>&1 >/dev/null
}

function StartServices() {
#########################################################################
service ldap start 2>&1 >/dev/null
service open-xchange start 2>&1 >/dev/null
}

function RestartServices() {
#########################################################################
service tomcat restart
service ldap restart  
service open-xchange restart  
}

function RestoreOX() {
DOMAIN=`/sbin/e-smith/db configuration get DomainName`
if [ -z $DOMAIN ]; then
echo "error : the domain is unknow"
exit 1
fi
if [ ! -f /home/e-smith/db/pgsql/ox_$DOMAIN.sql ]; then
echo "error : "
echo "file /home/e-smith/db/pgsql/ox_$DOMAIN.sql doesn't exists, unable to restore"
exit 1
fi
if [ ! -f /home/e-smith/db/ldap/$DOMAIN.ldif.bak ]; then
echo "error : "
echo "file /home/e-smith/db/ldap/$DOMAIN.ldif.bak doesn't exists, unable to restore"
exit 1
fi
if [ ! -d /home/e-smith/open-xchange ]; then
echo "error : "
echo "files /home/e-smith/open-xchange/ doesn't exists, unable to restore"
exit 1
fi

StopServices

##########################################################################
# LDAP
rm -f /var/lib/ldap/*
slapadd -l /home/e-smith/db/ldap/$DOMAIN.ldif.bak
chown -R ldap:ldap /var/lib/ldap
service ldap start 2>&1 >/dev/null

###########################################################################
# Postgresql

/sbin/e-smith/expand-template /var/lib/pgsql/data/postgresql.conf
/sbin/e-smith/expand-template /var/lib/pgsql/data/pg_hba.conf
chown -R postgres:postgres /var/lib/pgsql
chmod 600 /var/lib/pgsql/data/postgresql.conf
chmod 600 /var/lib/pgsql/data/pg_hba.conf

service postgresql start 2>&1 >/dev/null
su postgres -c'pg_dump -Fc -b openexchange -v' > /home/e-smith/db/pgsql/openexchange.sql.bak
su - -c'dropdb openexchange' postgres
su - -c'dropuser openexchange' postgres
su - -c'createdb -e --template=template0 -E UNICODE -e openexchange' postgres
su - -c'psql -a -e -d openexchange -e -f /usr/local/open-xchange/share/createuser.sql' postgres


#!/bin/bash
su postgres -c'pg_restore -Fc -d openexchange -v /home/e-smith/db/pgsql/ox_'$DOMAIN'.sql'

###############################################################################
# FILES

/usr/bin/rsync -aur --delete /home/e-smith/open-xchange/var /usr/local/open-xchange
/usr/local/open-xchange/sbin/scan_users.sh
   
StartServices
RestartServices

}
##############################################################################################################################################

function RestoreOXHA() {
DOMAIN=`/sbin/e-smith/db configuration get DomainName`
if [ -z $DOMAIN ]; then
echo "error : the domain is unknow"
exit 1
fi
if [ ! -f /home/e-smith/files/db/pgsql/ox_$DOMAIN.sql ]; then
echo "error : "
echo "file /home/e-smith/files/db/pgsql/ox_$DOMAIN.sql doesn't exists, unable to restore"
exit 1
fi
if [ ! -f /home/e-smith/files/db/ldap/$DOMAIN.ldif.bak ]; then
echo "error : "
echo "file /home/e-smith/files/db/ldap/$DOMAIN.ldif.bak doesn't exists, unable to restore"
exit 1
fi
if [ ! -d /home/e-smith/files/saves/open-xchange ]; then
echo "error : "
echo "files /home/e-smith/files/saves/open-xchange/ doesn't exists, unable to restore"
exit 1
fi

StopServices


##########################################################################
# LDAP
rm -f /var/lib/ldap/*
slapadd -l /home/e-smith/files/db/ldap/$DOMAIN.ldif.bak
chown -R ldap:ldap /var/lib/ldap
service ldap start 2>&1 >/dev/null

###########################################################################
# Postgresql

/sbin/e-smith/expand-template /var/lib/pgsql/data/postgresql.conf
/sbin/e-smith/expand-template /var/lib/pgsql/data/pg_hba.conf
chown -R postgres:postgres /var/lib/pgsql
chmod 600 /var/lib/pgsql/data/postgresql.conf
chmod 600 /var/lib/pgsql/data/pg_hba.conf

service postgresql start 2>&1 >/dev/null
su postgres -c'pg_dump -Fc -b openexchange -v' > /home/e-smith/files/db/pgsql/openexchange.sql.bak
su - -c'dropdb openexchange' postgres
su - -c'dropuser openexchange' postgres
su - -c'createdb --template=template0 -E UNICODE -e openexchange' postgres
su - -c'psql -a -e -d openexchange -e -f /usr/local/open-xchange/share/createuser.sql' postgres


#!/bin/bash
su postgres -c'pg_restore -d openexchange -v /home/e-smith/db/pgsql/ox_'$DOMAIN'.sql'


###############################################################################
# FILES

/usr/bin/rsync -aur --delete /home/e-smith/files/saves/open-xchange/var /usr/local/open-xchange
/usr/local/open-xchange/sbin/scan_users.sh

StartServices
RestartServices

}
###################################################################################################################
# check for heartbeat system
if [ -x /usr/local/sbin/getnode ]; then
MYNODE=`getnode`
HERIP=`getnode --mirror --ip`
HERNAME=`getnode --mirror`
# first thing verify if whe are the active node
ACTIV=`/sbin/e-smith/db heartbeat getprop nodes Active`

if [ $MYNODE == $ACTIV ]; then
RestoreOXHA
fi
else
RestoreOX
fi


/usr/local/open-xchange/share/rebuild_db.sh

Code: [Select]
#!/bin/bash
# create de postgresql database for OX
# by filali.v@free.fr
# Vincent FILALI-ANSARY
#

[ ! -d /home/e-smith/db/pgsql ] && mkdir /home/e-smith/db/pgsql
su postgres -c'pg_dump -Fc -b openexchange -v' >/home/e-smith/db/pgsql/openexchange.sql.back

su - -c'dropdb openexchange' postgres
su - -c'dropuser openexchange' postgres

su - -c'createdb -e --template=template0 -E UNICODE -e openexchange' postgres
su - -c'psql -a -e -d openexchange -e -f /usr/local/open-xchange/share/createuser.sql' postgres
#su - -c'createuser -A -d -P -E -e openexchange' postgres
#su - -c'createdb -O openexchange -E UNICODE -e openexchange' postgres
su - -c'psql -a -e -d openexchange -f /usr/local/open-xchange/share/init_database.sql' postgres
su - -c'psql -a -e -d openexchange -f /usr/local/open-xchange/share/admin_last.sql' postgres

if [ -x /usr/local/open-xchange/share/add_syncml_db.sh ]; then
. /usr/local/open-xchange/share/add_syncml_db.sh
fi


/usr/local/open-xchange/sbin/deluser_ox

Code: [Select]
#!/bin/bash
#
# (c) 2004-2100  
# Author: cutmasta AT netline-is D0T de
#
#
# This Script dels OX User from the LDAP!
# TODO : DELETE personal adressbook completely if he has entries in that!
#
#
# GLOBAL CONFIGFILE
prefix=/usr/local/open-xchange
exec_prefix=${prefix}

GLOBAL_CONF="${prefix}/etc/admintools.conf"

if [ -f $GLOBAL_CONF ]
then
. $GLOBAL_CONF
else
echo "Config File $GLOBAL_CONF not found."
exit 0
fi

ac_prev=
for ac_option
do
if test -n "$ac_prev"; then
eval "$ac_prev=\$ac_option"
ac_prev=
continue
fi
case "$ac_option" in
-*=*) ac_optarg=`echo "$ac_option" | $SED_BIN 's/[-_a-zA-Z0-9]*=//'` ;;
*) ac_optarg= ;;
esac

case "$ac_option" in

--username)
ac_prev=username ;;
--username=*)
USERNAME=$ac_optarg ;;



-help | --help | -? | --?)

cat <<EOF

Usage: $0 [Options]

Options:
--username=NAME The Username - eg. john

EOF

exit 0

;;

*)
echo "Unknown command $ac_option"
echo "Try $0 --help"
exit 1
;;
esac

done

ERROR=

if [ "$USERNAME" = "" ]
then
ERROR="y"
echo "Specify an Username!"
fi


if [ "$ERROR" = "y" ]
then
echo "Please provide an Username!"
echo "Try $0 --help"
exit 0 ;
fi

#LDAP_DELETE_ADR=`$LDAPDELETE_BIN $LDAPCONN "ou=addr,uid=$USERNAME,$USER_BASEDN" 2>&1 | $GREP_BIN Delete | $AWK_BIN -F'(' {'print $2'} | $AWK_BIN -F')' {'print $1'}`

## DELETE RECURSIVE ALL USER STUFF FROM LDAP
LDAP_DELETE=`$LDAPDELETE_BIN $LDAPCONN -r "uid=$USERNAME,$USER_BASEDN" 2>&1 | $GREP_BIN Delete | $AWK_BIN -F'(' {'print $2'} | $AWK_BIN -F')' {'print $1'}`


# delete the user from the adressadmins
echo "dn: $GLOBAL_ADDRESSBOOK_ADMINSDN " > $TMPDIF
echo "changetype: modify" >> $TMPDIF
echo "delete: member" >> $TMPDIF
echo "member: uid=$USERNAME,$USER_BASEDN" >> $TMPDIF

LDAP_DELETE_ADDRESSADMIN=`$LDAPMODIFY_BIN $LDAPCONN -f $TMPDIF 2>&1 | $GREP_BIN ldap_modify | $AWK_BIN -F'(' {'print $2'} | $AWK_BIN -F')' {'print $1'}`
rm $TMPDIF

OX_OBJECTS_DELETE=`/usr/local/java/bin/java -Dopenexchange.propfile=/usr/local/open-xchange/etc/groupware/system.properties -classpath /usr/local/open-xchange/lib/intranet.jar:/usr/local/open-xchange/lib/comfiretools.jar:/usr/local/open-xchange/lib/nas.jar:/usr/local/share/java/pg74.216.jdbc3.jar com.openexchange.groupware.deleteUserGroups deleteUser $USERNAME`

esc=`echo -en "\033"`
warn="${esc}[1;31m"
done="${esc}[1;32m"
info="${esc}[1;33m"

case "$LDAP_DELETE" in

"")
echo "${done}LDAP Success!"

if [ "$SQL_DB_TYPE" = "pgsql" ]
then

SQL_INSERT=`$SQL_BIN -h $DEFAULT_SQL_HOST -U $DEFAULT_SQL_USER -d $DEFAULT_SQL_DB -X -c "DELETE FROM $RIGHTS_TABLE WHERE login LIKE '$USERNAME'" | $AWK_BIN {'print $1'}`
if [ $? -eq 0 ]; then
SQL_INSERT="DELETE"
fi
else

SQL_INSERT=`$MYSQL_BIN -h $DEFAULT_SQL_HOST -u $DEFAULT_SQL_USER --password=$DEFAULT_SQL_PASS $DEFAULT_SQL_DB -e "DELETE FROM $RIGHTS_TABLE WHERE login LIKE '$USERNAME'" `

fi


if [ "$SQL_INSERT" = "DELETE" ]
then
echo "${done}SQL Success"
else
echo "${warn}SQL Error"
exit 0
fi
;;
32)
echo "${info}No such User"
;;
34)
echo "${warn}invalid DN"
;;
*)
echo "${warn}Undefined ERROR - LDAP CODE $LDAP_INSERT"
echo "${warn}See LDAP Log for Details!"
esac

echo -en "${esc}[m\017"
echo -n ""


Nach jedem signal-event post-upgrade wird das restore_ox ausgeführt. Da im normal Fall danach ein signal-event reboot folgt, kann in dem Script restore_ox der RestartServices auch auskommentiert werden.

yythoss