Get the App
SLTechnology News&Howtos  ›  Database  › 

How to back up Oracle database regularly in different places

Shulou Source: shulou.com Published: 2022-05-31 18:43:25 10月02日 Update

This article mainly explains "how to regularly back up Oracle database". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to back up Oracle database regularly".

1) set deferred_segment_creation parameters

The following setting allocates segment space whether the table is empty or not.

Su-oraclesqlplus / as sysdbaSQL > show parameter deferred_segment_creation

Note: the default value of this parameter is TRUE, and when changed to FALSE, segment is assigned to both empty and non-empty tables.

SQL > alter system set deferred_segment_creation=false

Note: this value setting has no effect on previously imported empty tables, still can not be exported, can only have an effect on later new tables.

Restart the database service

2) configure ssh trust

Configure ssh trust, and the scp command in the backup script can transfer files to the slave server (192.168.1.21) without a password

Execute on the primary server:

Ssh-keygen-t rsa / / you can enter cd / root/.ssh/scp id_rsa.pub root@192.168.1.21:/root/.ssh/ all the time.

Execute on the slave server:

Cd / root/.ssh/mv id_rsa.pub authorized_keys

In this way, scp can copy files to the slave server without password on the master server.

3) automatic backup script

First create a backup file storage directory on the slave server

Mkdir-p / home/backup/oracledata/chmod 777 / home/backup/oracledata/

Scripting on the primary server

Vim / home/backup/oracledata/oraclebk.sh

# / usr/bin# path name, specify the backup path FILEPATH=/home/backup/oracledata # define the backup database file name FILENAME= `date + "% Y%m%d_%H%M" `# switch to the specified path and create a folder cd $FILEPATHmkdir $FILENAMEchmod 775$ FILENAME # oracle variable to set export USER=oracle;export ORACLE_SID=ecology;export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1;export PATH=$ORACLE_HOME/bin:$PATH # Export database exp ecology/ecology file= "$FILENAME/$FILENAME" .DMP log= "$FILENAME/$FILENAME" .log owner=ecology # package tar-zcvf $FILENAME.tar.gz $FILENAMErm-rf $FILENAMEscp $FILENAME.tar.gz root@192.168.1.21:$FILEPATH/find. /-mtime + 15-name\ * .gz | xargs rm-fexitEOF

4) add scheduled tasks

Crontab-e00 03 * sh / home/backup/oracledata/oraclebk.sh

5) restart crond service

Systemctl restart crond.service

Thank you for your reading, the above is the content of "how to regularly back up the Oracle database". After the study of this article, I believe you have a deeper understanding of the problem of how to back up the Oracle database on a regular basis, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Backup service data database server file offsite script path learning function content parameter password assignment configuration editor task variable command Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker macOS OPPO Reno MySQL