Example execute below command from root
# vi /soft/Nano_Ora_Export.sh
#!/bin/bash
now="$(date +'%d%m%Y')"
ORA_HOME=/DATABASE/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_HOME=/DATABASE/u01/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/exp userid=user_schema/user_pass@db_name statistics=none full=N owner=user1,user2 consistent=y file=/soft/DBUser1User2"$now"DB.dmp log=/soft/DBUser1User2"$now".log";
zip -r /var/www/DBUser1User2"$now"DB.zip /soft/DBUser1User2"$now"DB.dmp;
exit $?
After that execute below command:
# chmod 750 /soft/Nano_Ora_Export.sh
Now, you can set this file to your crontab location to export database automatically.
# vi /soft/Nano_Ora_Export.sh
#!/bin/bash
now="$(date +'%d%m%Y')"
ORA_HOME=/DATABASE/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_HOME=/DATABASE/u01/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/exp userid=user_schema/user_pass@db_name statistics=none full=N owner=user1,user2 consistent=y file=/soft/DBUser1User2"$now"DB.dmp log=/soft/DBUser1User2"$now".log";
zip -r /var/www/DBUser1User2"$now"DB.zip /soft/DBUser1User2"$now"DB.dmp;
exit $?
After that execute below command:
# chmod 750 /soft/Nano_Ora_Export.sh
Now, you can set this file to your crontab location to export database automatically.
No comments:
Post a Comment