当前位置:网站首页>Oracle11g database uses expdp to back up data every week and upload it to the backup server
Oracle11g database uses expdp to back up data every week and upload it to the backup server
2022-06-28 15:05:00 【1024 Q】
1. Look at the database
1.1 First, let's take a look at the table space , The production environment table space is about 90G, Less than half of it was used
2. Database backup
2.1 Login database
2.2 Create a logical Directory
2.3 Give database user file operation permission #dbuser User name for database , More practical changes
2.3 Create a physical Directory
1.3 Backup database
3.shell Script for automatic backup
4. Add timing task
4. Reference article
The school needs to back up the previous production database to Huawei cloud , After that, automatic weekly backup will be realized
1. Look at the database 1.1 First, let's take a look at the table space , The production environment table space is about 90G, Less than half of it was usedView all tablespaces and usage
SELECT B.FILE_NAME Physical file name , B.TABLESPACE_NAME Tablespace name , B.BYTES/1024/1024 size M, (B.BYTES-SUM(NVL(A.BYTES,0)))/1024/1024 Already used M, SUBSTR((B.BYTES-SUM(NVL(A.BYTES,0)))/(B.BYTES)*100,1,5) Usage rate FROM DBA_FREE_SPACE A,DBA_DATA_FILES BWHERE A.FILE_ID=B.FILE_IDGROUP BY B.TABLESPACE_NAME,B.FILE_NAME,B.BYTESORDER BY B.TABLESPACE_NAME;
[[email protected]]$ sqlplus / as sysdba
2.2 Create a logical Directory This operation will not be performed in Linux Created in /opt/data_backup This file , Finally, you need to create the file manually to back it up .
SQL> create directory back_dir as '/opt/backup'SQL> select * from dba_directories; # View all logical directories , See if the creation is successful
2.3 Give database user file operation permission #dbuser User name for database , More practical changes Grant read,write on directory back_dir to dbuser;
2.3 Create a physical Directory [[email protected]]$ mkdir -p /opt/backup #-p Ensure that the directory name exists , It does not exist to build a , You can use parameters to create multi-level directories
1.3 Backup database [[email protected]]$ expdp dbuser/[email protected]:1521/orcl dumpfile=dbback.dmp log=log.log directory=back_dir schemas=cbyxy
exedp There are a lot of parameters , Here are some explanations used
dbuser/[email protected]:1521/orcl # Export user name / password @ database IP/ database SID
dumpfile= Exported file name .dmp
log= Log name of the export process .log
directory= The path name of the backup file , Use the previous logical directory name
schemas= The name of the database user to be backed up
FULL=y # This means that you do not need to export the entire database schemas Parameters
You can also export by tablespace TABLESPACES=
Table name export TABLES=
And so on. There are many parameters you can learn by yourself
#!/bin/bash# Import environment variables , Fill in according to your actual situation export ORACLE_BASE=/home/oracle/appexport ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1export PATH=$ORACLE_HOME/bin:$PATHexport LOCAL_IP=192.168.110.183:1521export [email protected]:/opt/ # Backup server users ,ip, Save address export ORACLE_USER_NAME=system # The user password of the database shall be filled in according to the actual situation , Backing up the entire library is best done with system or sys Administrator user export ORACLE_USER_PASSWD=Abc123556..export ORACLE_SID=orcl # I don't know if I can use Oracle User execution echo $ORACLE_SID, perhaps SQL> SELECT instance_name FROM v$instanceexport DATA_DIR=/opt/backup # Same as the logical address in the database , Used to store backup files export DELTIME=`date -d "7 days ago" +%Y%m%d` # -d "7 days ago" To get the date seven days ago , Name the task by date to facilitate automatic deletion of tasks > except export BAKUPTIME=`date +%Y%m%d` # Backup date: export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK # Environment variables that define language locale and character set attributes , Modify according to your own database mkdir -p $DATA_DIRecho "Starting bakup..."echo "Backup file path $DATA_DIR/$BAKUPTIME.dmp"expdp $ORACLE_USER_NAME/[email protected]$LOCAL_IP/$ORACLE_SID dumpfile=$BAKUPTIME.dmp log=$BAKUPTIME.log directory=expdp full=yecho "backup file success..."tar -zcvPf $DATA_DIR/$BAKUPTIME.tar.gz $DATA_DIR/$BAKUPTIME.dmp --remove-files ##-P: Specify the absolute path --remove-files : Delete the original file after packaging echo "tar the file backup successfully"echo "scp to":$BACKUP_IPscp $DATA_DIR/$BAKUPTIME.tar.gz $BACKUP_USER_IP_DIR # The remote server firewall has restrictions scp Port needs to be added :-P Port number rm -f $DATA_DIR/$DELTIME.log # Delete previous backup echo "Bakup completed."
[[email protected] ]$ crontab -e
add rows :* 1 * * 6 /opt/back.sh # Perform the backup task every Saturday morning
* * * * *- - - - -| | | | || | | | +----- What day of the week (0 - 6) ( Sunday by 0)| | | +---------- month (1 - 12) | | +--------------- Day of the month (1 - 31)| +-------------------- Hours (0 - 23)+------------------------- minute (0 - 59)
4. Reference article https://www.cnblogs.com/xwdreamer/p/3511047.html
https://www.cnblogs.com/farmer-y/p/5888432.html
https://blog.csdn.net/weixin_41607523/article/details/110817646
https://blog.csdn.net/XUEYUTIANQI/article/details/113976558
This is about Oracle 11g Database usage expdp This is the end of the article on weekly data backup and uploading to the backup server , More about Oracle 11g Use expdp Please search the previous articles of SDN or continue to browse the related articles below. I hope you can support SDN more in the future !
边栏推荐
- Unable to create process using 'd:\program file
- What is the renewal fee for PMP certificate?
- Facebook! Adaptive gradient defeats manual parameter adjustment
- 兼顾企业抗疫和发展的5个解决方案,来自IBM
- Jackie Chan and fast brand, who is the Savior of Kwai?
- Leetcode 48. Rotate image (yes, resolved)
- 竞远安全冲刺创业板:拟募资4亿 启元投资与云游软件是股东
- Successful cases of rights protection of open source projects: successful rights protection of SPuG open source operation and maintenance platform
- 名创优品通过上市聆讯:寻求双重主要上市 年营收91亿
- Differences between ram ROM flash
猜你喜欢
随机推荐
Facebook! Adaptive gradient defeats manual parameter adjustment
笔试面试算法经典–最长回文子串
Leetcode 48. Rotate image (yes, resolved)
Functools: high order functions and operations on callable objects (continuous updating ing...)
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和数据表格横向组合起来形成最终结果图
Mingchuangyou products passed the listing hearing: seeking dual main listing with an annual revenue of 9.1 billion
技术弄潮儿
dolphinscheduler2.X的安装(亲测有效)
字节跳动埋点数据流建设与治理实践
利用MySqlBulkLoader实现批量插入数据的示例详解
Softing epgate Pb series Gateway - integrates the Profibus bus into the ethernet/ip network
[Zhongyi Xinsheng] 5 SPI interface test TF Card
PMP真的有用吗?
Performance comparison of deep learning models on cat and dog image data sets
力扣今日题-522. 最长特殊序列
Recommended practice sharing of Zhilian recruitment based on Nebula graph
Leetcode(88)——合并两个有序数组
Setsql function and risk of using lamdbaupdatewrapper
spacy教程(持续更新ing...)
Construction and management practice of ByteDance buried point data flow