Here is a very simple script to save an Oracle database with a full export script.
It’s a very basic example, because there is no log and no option (only a full export)
Ina few days i’ll post a more detailled export script.
#!/bin/bash
#—————————#
# Oracle Full export script #
# Nuxora v1.0 #
#—————————#
# set env
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
export ORACLE_SID=$1
when=`date +”%d%m”`
# export
exp expimp/$2 file=”$ORACLE_BACKUP”/admin/exp/full/$ORACLE_SID/exp”$when”_”$ORACLE_SID”_”FULL”.dmp FULL=Y ROWS=Y
# keep only 7 days
for file in `find “$ORACLE_BACKUP/admin/exp/full/$ORACLE_SID” -name “exp*.dmp” -mtime +7 -print`
do
echo $file
rm $file
done
I’ll try to write a tutorial on TAF, it seems to be very efficient but i’ve never really used it in real condition, just test. If you want to connect to TAFTEST, first it will try ton connect to NUXORA01, if something’s wrong it will try to connect to NUXORA02
DBPROD =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = NUXORA01)(PORT = 1521))
(CONNECT_DATA =
(SID = ORADB01)
)
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = NUXORA02)(PORT = 1521))
(CONNECT_DATA =
(SID = ORADB02)
)
)
)
#Dump of the master database
$ mysqldump -u user -p db_test > /var/dump/db_test.dat
#Copy the dump file db_test.dat with scp to the slave mysql database
$ scp /var/dump/db_test.dat user@nuxora.com:/var/backup/db_test.dat
#Restore database on the slave server from the master server
$ ssh user@nuxora.com ‘mysql -u user -p db_test < /var/backup/db_test.dat’
it is quite simple and efficient.
But if you are a real geek you’d prefer this one:
#Dump from master database to slave one with ssh
$ mysqldump db_test | ssh user@nuxora.com mysql db_test
L’export constitue une méthode simple pour sauvegarder une base ou pour la deplacer, il faut toutefois garder à l’esprit que l’export doit etre consistant, il n’y doit pas y avoir demodifications sur la base au cours d’un export.
Pour le réaliser, il faut d’abord créer un utilisateur nommé import ou export ou impexp
CREATE USER EXPIMP IDENTIFIED BY xxxxxxxx DEFAULT TABLESPACE TOOLS TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;
GRANT EXP_FULL_DATABASE TO EXPIMP;
GRANT IMP_FULL_DATABASE TO EXPIMP;
GRANT CREATE SESSION TO EXPIMP;
ALTER USER EXPIMP DEFAULT ROLE ALL;
Puis lancer un script sql, sous le compte SYS.
sqlplus /nolog
sql> connect sys as sysdba
pour une 9.2
SQL > @/u01/app/oracle/product/9.2.0/rdbms/admin/catexp.sql
pour une 10g
SQL > @/u01/app/oracle/product/10.x.0/db_1/rdbms/admin/catexp.sql
SQL > quit
à partie de la, on peut realiser un import ou un export: