Mikiwiki:Portal: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Michi (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Michi (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 18: | Zeile 18: | ||
* http://mikiwiki.org/wiki/Spezial:Version | * http://mikiwiki.org/wiki/Spezial:Version | ||
<!-- | |||
sisis@aesch:~/bin> more SybSave-AESCH.sh | |||
#!/bin/bash | |||
# | |||
# Name SybSave-AESCH.sh | |||
# Author Michael Kuhn, OCLC AG | |||
# Date 2010.07.13 | |||
# Description Use these parameters | |||
# - nothing or "full" will dump database and dump transactio | |||
# (with log truncation) | |||
# - "trans" will dump transaction (log truncation) | |||
set -a # export all variables | |||
set -e # stop at errors | |||
set -x | |||
##### MANUAL CONFIGURATION ##### | |||
# Databases to be backed up | |||
# | |||
DATABASESTOBACKUP="sisis" | |||
# Path and name of the file for dump database (without closing "/") | |||
# NOTE: You must make sure that both users "sisis" and "sybase" have write | |||
# permission in the directory because the dump is done by Sybase as "sybase" | |||
# and other work as "sisis" | |||
DBSAVEPATH="/backup/SYBASE" | |||
# Path for dump transactions (without closing "/") | |||
# | |||
TRANSDUMPPATH="/SunRiseDatabaseLog/logSave" | |||
# Transaction logs older than $TRANS_DEL days will be removed | |||
# | |||
TRANS_DEL=10 | |||
##### AUTOMATIC CONFIGURATION ##### | |||
# Get the values from syb.rc | |||
# | |||
PATH=$PATH:/usr/local/bin | |||
. $(pkgparam sisisbase SISISROOT)/etc/syb.rc | |||
if [ "$(echo ${SC_SQL} | grep -q 12_5 ; echo $?)" = 0 ]; then | |||
export LANG=de | |||
elif [ "$(echo ${SC_SQL} | grep -q 15_0 ; echo $?)" = 0 ]; then | |||
export LANG=de_DE.UTF-8 | |||
else | |||
echo "Unknown Sybase version. No connection possible" | |||
exit 1 | |||
fi | |||
SYBASEUSER=sa | |||
PASSWORD=$(cat ${SISISROOT}/etc/syb/syb.pw | \ | |||
grep ^${SYBASEUSER}: | awk -F: '{ print $2 }' | tr -d '\012') | |||
SYBASELOGIN="${SC_SQL} -U${SYBASEUSER} -P${PASSWORD} -S${DSQUERY}" | |||
DUMPSUFFIX=$(date "+.%F-%H%M%S") | |||
##### MAIN PROGRAM ##### | |||
for i in ${DATABASESTOBACKUP} | |||
do | |||
DATABASE=${i} | |||
DBSAVEFILE=${DBSAVEPATH}/DBSAVE${DATABASE}.cdmp | |||
TRANSDUMPFILE=${TRANSDUMPPATH}/${DATABASE}/${DATABASE}${DUMPSUFFIX} | |||
if [ $# -eq 0 ]; then | |||
SAVEMODE="full" | |||
else | |||
case $1 in | |||
full) SAVEMODE="full" | |||
printf "\nsaving complete database %s\n\n" ${DATABASE} | |||
NOTRUNCOPT="" | |||
;; | |||
trans) SAVEMODE="trans" | |||
NOTRUNCOPT="" | |||
printf "\nsaving transaction logs of database %s\n\n" ${DATABASE} | |||
;; | |||
trans_notrunc) SAVEMODE="trans" | |||
NOTRUNCOPT="with no_truncate" | |||
printf "\nsaving transaction logs of database %s " | |||
printf "without truncate logs\n\n" ${DATABASE} | |||
;; | |||
*) printf "unknown mode [%s] - exit\n" $1 | |||
exit 1 | |||
;; | |||
esac | |||
fi | |||
set +e | |||
# let's see if we can connect at all | |||
${SYBASELOGIN} < /dev/null > /dev/null | |||
if [ $? -ne 0 ]; then | |||
printf "Can't connect to Sybase server\n" | |||
exit 1 | |||
fi | |||
set -e | |||
# full: dump database | |||
if [ ${SAVEMODE} = "full" ]; then | |||
if [ ! -f ${DBSAVEFILE} ]; then | |||
touch ${DBSAVEFILE} && chmod 777 ${DBSAVEFILE} | |||
else | |||
mv -f ${DBSAVEFILE} ${DBSAVEFILE}-OLD | |||
fi | |||
printf "dump database ${DATABASE} to \"${DBSAVEFILE}\" | |||
with compression=6\ngo\n" | ${SYBASELOGIN} | |||
for i in /media/FLASHDRIVE | |||
do | |||
sleep 10 | |||
if [ -f ${i}/dont-remove-me ]; then | |||
sudo /bin/cp /backup/SYBASE/DBSAVEsisis.cdmp ${i} && \ | |||
DATUM=$(date "+%e. %B %Y %H:%M") && \ | |||
echo "$DATUM Sicherung auf USB-Stick $i verschoben!" > \ | |||
/usr/local/sisis-pap/tomcat/webapps/ROOT/sicherung-usb.txt && \ | |||
sync && \ | |||
sudo /bin/umount ${i} | |||
else | |||
sudo /bin/mount /dev/sdb1 ${i} && \ | |||
sudo /bin/cp /backup/SYBASE/DBSAVEsisis.cdmp ${i} && \ | |||
DATUM=$(date "+%e. %B %Y %H:%M") && \ | |||
echo "$DATUM Sicherung auf USB-Stick $i verschoben!" > \ | |||
/usr/local/sisis-pap/tomcat/webapps/ROOT/sicherung-usb.txt && \ | |||
sync && \ | |||
sudo /bin/umount ${i} | |||
if [ $? != 0 ]; then | |||
DATUM=$(date "+%e. %B %Y %H:%M") | |||
echo "$DATUM Sicherung konnte nicht auf USB-Stick verschoben \ | |||
werden! Womöglich war der USB-Stick nicht eingesteckt." > \ | |||
/usr/local/sisis-pap/tomcat/webapps/ROOT/sicherung-usb.txt | |||
fi | |||
fi | |||
done | |||
set +e | |||
find ${TRANSDUMPPATH}/${DATABASE} -mtime +${TRANS_DEL} -exec rm -f {} \; | |||
set -e | |||
fi | |||
# dump transaction | |||
printf "dump transaction ${DATABASE} to \"${TRANSDUMPFILE}\" | |||
${NOTRUNCOPT} compression=6\ngo" | ${SYBASELOGIN} | |||
done | |||
--> | |||
{{cat|Mikiwiki}} | {{cat|Mikiwiki}} |
Version vom 22. Juli 2010, 14:52 Uhr
Die Inhalte des "Mikiwiki:Portal" sind ausschliesslich für interne Zwecke gedacht, enthalten also keine für das Publikum gedachten Inhalte.