[SOLVED] schedule a bash script to move recent/latest dump files from server(rhel 5.7) system to another system(rhel 7.5)
Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
schedule a bash script to move recent/latest dump files from server(rhel 5.7) system to another system(rhel 7.5)
hello all,
i am a newbie in Linux OS , hence need help in below problem.
i have below bash script where i have been taking whole sys user oracle backup and storing it in server itself.
ie,
#!/bin/bash
# file : /home/oracle/app/expbkp_TESTONE.sh
# description : run export backup to localdisk
##########################
##### Variables #######
##########################
RUNTIME=`date '+%H%M_%d%m%Y'`
RUNDATE=`date '+%d%m%Y'`
export LD_LIBRARY_PATH=/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib
export ORACLE_SID=oracle
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:${ORACLE_HOME}/bin
# start the Export backup
expdp "/ as sysdba" directory=EXP_IMP_DIR dumpfile=${ORACLE_SID}_tmk_${RUNTIME}.dmp logfile=${ORACLE_SID}_tmk_${RUNTIME}.log full=y
#########################################################################
#Removing 3 days old dump files
find /home/oracle/expdp_impdp_oracle -mtime +2 -exec rm {} \;
As of date, i have been using scp to manually copy/move recent/latest dump files from host server(rhel 5.7) to backup system (rhel 7.5).
i need help in writing bash script to automate the copying/moving of recent/latest dump files from host server (rhel 5.7) to another system (rhel 7.5).
Alternatively, after running the original script, use rsync to copy dump files to the RHEL7.5 server. rsync is great at only copying what is not on the destination already. I would need a few additional minutes to dig out the required command line options.
Alternatively, explore whether the expdp program support remote destinations.
It does worry me a little that your script is named TESTONE...
but by using this command i need to specify which file i am transferring to the other system, i need script which takes latest (dump and log) files to be copied/moved from rhel 5.7 server system to rhel 7.5 backup system.
Master table "SYS"."SYS_EXPORT_FULL_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_FULL_01 is:
/home/oracle/expdp_impdp_oracle/oracle_tmk_1453_20022020.dmp
Job "SYS"."SYS_EXPORT_FULL_01" successfully completed at 14:55:46
oracle_tmk_1453_20022020.dmp: No such file or directory
oracle_tmk_1453_20022020.log: No such file or directory
sir ,
after running the bash script backup file is saving in the given directory, but for scp command that directory is not getting looked up!
after running above scripts , i am getting the error as below while sending the latest file to another system through scp
Dump file set for SYS.SYS_EXPORT_FULL_01 is:
/home/oracle/expdp_impdp_oracle/oracle_tmk_1453_20022020.dmp
Job "SYS"."SYS_EXPORT_FULL_01" successfully completed at 14:55:46
oracle_tmk_1453_20022020.dmp: No such file or directory
oracle_tmk_1453_20022020.log: No such file or directory
the underlined command's are giving the issue while transferring the file to another system
#!/bin/bash
# file : /home/oracle/app/expbkp_TESTONE.sh
# description : run export backup to localdisk
##########################
##### Variables #######
##########################
RUNTIME=`date '+%H%M_%d%m%Y'`
RUNDATE=`date '+%d%m%Y'`
export LD_LIBRARY_PATH=/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib
export ORACLE_SID=oracle
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:${ORACLE_HOME}/bin
DUMPFILE=${ORACLE_SID}_tmk_${RUNTIME}.dmp
LOGFILE=${ORACLE_SID}_tmk_${RUNTIME}.log
# start the Export backup
expdp "/ as sysdba" directory=EXP_IMP_DIR dumpfile=$DUMPFILE logfile=$LOGFILE full=y
#########################################################################
#Removing 3 days old dump files
find /home/oracle/expdp_impdp_oracle -mtime +2 -exec rm {} \;
cd /home/oracle/expdp_impdp_oracle
scp $DUMPFILE $LOGFILE root@10.0.1.145:/home/ksrtc/bkp
sir i changed this code scp $DUMPFILE $LOGFILE root@10.0.1.145:/home/ksrtc/bkp to scp /home/oracle/expdp_impdp_oracle/$DUMPFILE /home/oracle/expdp_impdp_oracle/$LOGFILE root@10.0.1.145:/home/ksrtc/bkp
but here the password for the destination machine is been asked , how to automate and the ssh password , which will take the password automatically and tranfer the dump file to destination system
sir, everything is working fine except for password! after all the exporting , the scp command is asking for password to transfer the file. though the ssh keys have been created . while manually using scp command in terminal, the password is not been asked ,, but the scp command at last of the bash script, the password is been asked, here how to automate, so that the password in not asked for the below scp command
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.