Sql backup > Mail

Pagina: 1
Acties:

  • Xboty
  • Registratie: September 2003
  • Laatst online: 19-02 12:07
Ik gebruik het volgende script om alle databases op m'n sql server te backuppen in een .tgz
code:
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
#!/bin/sh
USER="*****"
PASS="*****"
BASEDIR=/tmp/sqlbackup
TIME=$(date)
LOGFILE=/tmp/mysql-log.log
#Print info in logfile
echo "#############START####################" > $LOGFILE
echo "#### $TIME ####" >> $LOGFILE
echo "######################################" >> $LOGFILE
#Start script
echo !!! Directorys maken en chmodden >> $LOGFILE
mkdir $BASEDIR
chmod 777 $BASEDIR
echo !!! Databases uitlezen en dumpen  >> $LOGFILE
mysqlshow --user=$USER --password=$PASS | {
  while read a dbnaam rest ;
    do
    if [ $a != "+" -a $a != "Databases" ] ;
     then
     mysqldump --user=$USER --password=$PASS $dbnaam > $BASEDIR/$dbnaam.sql
     echo $dbnaam Gedumped >> $LOGFILE
    fi
  done
}
echo !!! Start Tarball >> $LOGFILE
tar -czf /tmp/backupsql.tgz $BASEDIR >> $LOGFILE
rm -rf /tmp/sqlbackup
echo "#############END#######################" >> $LOGFILE
echo "#### $TIME #####" >> $LOGFILE
echo "#######################################" >> $LOGFILE


Nu wil ik dat ie controleerd of het backuppen gelukt is en de tarball bestaat, vervolgens moet hij een mailtje sturen of als dat wel gelukt is, en als het niet gelukt is ook, met een ander onderwerp.

  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 20-02 14:52

gorgi_19

Kruimeltjes zijn weer op :9

En wat lukt je niet? Waar zit het probleem?

Digitaal onderwijsmateriaal, leermateriaal voor hbo


  • Xboty
  • Registratie: September 2003
  • Laatst online: 19-02 12:07
Het probleem is dat ik niet weet hoe ik kan controleren of de backup wel of niet gelukt is

  • whoami
  • Registratie: December 2000
  • Laatst online: 16:46
OS specifieke scripts horen niet thuis in P&W, maar in het specifieke OS forum

-> NOS

https://fgheysels.github.io/


  • Justin_Time
  • Registratie: Juni 2001
  • Laatst online: 17-07-2025
d.m.v een if contructie
code:
1
2
3
4
5
6
if [ -e $FILE ]; then
        echo "hij is er"
  else
        echo;
        echo "The file $FILE doesn't exist!
fi;


man sh

Elke dag dronken is ook een geregeld leven.