Pages

Sunday, January 10, 2016

expdp and crontab example. Export several schemas from script

=======================================
General
=======================================
Create a crontab task, that would expdb several schemas, and then zip the generated dmp and log files.

crontab task
user@xxx.xxx.xxx.121:~/workarea/EXP_IMP>% crontab -l
0 3 * * * /starhome/iu/workarea/EXP_IMP/main_exp.sh

main script
user@xxx.xxx.xxx.121:~/workarea/EXP_IMP>% less main_exp.sh
#!/bin/bash
./export_all_db.sh
./zip_all_export_files.sh

export all schemas
user@xxx.xxx.xxx.121:~/workarea/EXP_IMP>% less export_all_db.sh
#!/bin/bash
./exp.cmd parfile=exp_tza_vodac_ipnqq.prm
./exp.cmd parfile=exp_tza_vodac_ipnqq_reports.prm
./exp.cmd parfile=exp_tza_vodac_irmqq.prm
./exp.cmd parfile=exp_tza_vodac_irmqq_reports.prm
./exp.cmd parfile=exp_tza_vodac_rptqq.prm
./exp.cmd parfile=exp_tza_vodac_sfiqq.prm
./exp.cmd parfile=exp_tza_vodac_sparx.prm
./exp.cmd parfile=exp_tza_vodac_sparx_reports.prm
exit 0

single schema expdp command
user@xxx.xxx.xxx.121:~/workarea/EXP_IMP>% less exp.cmd
expdp system/pass@igt $1

single schema expdp parameters file
user@xxx.xxx.xxx.121:~/workarea/EXP_IMP>% less exp_tza_vodac_ipnqq.prm
DIRECTORY=IG_EXP_DIR
DUMPFILE=exp_tza_vodac_ipnqq.dmp
LOGFILE=exp_tza_vodac_ipnqq.log
SCHEMAS=TZA_VODAC_IPNQQ
REUSE_DUMPFILES=YES

zip generated files
user@xxx.xxx.xxx.121:~/workarea/EXP_IMP>% less zip_all_export_files.sh
#!/bin/bash
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_ipnqq.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_ipnqq.log
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_ipnqq_reports.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_ipnqq_reports.log
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_irmqq.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_irmqq.log
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_irmqq_reports.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_irmqq_reports.log
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_rptqq.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_rptqq.log
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_sfiqq.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_sfiqq.log
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_sparx.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_sparx.log
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_sparx_reports.dmp
gzip -f /starhome/iu/workarea/ora_exp/exp_tza_vodac_sparx_reports.log

No comments:

Post a Comment