当前位置:网站首页>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 sysdba2.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=cbyxyexedp 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 -eadd 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 !
边栏推荐
- 华为能成“口红一哥”,或者“带货女王”吗?
- How can I get the stock account opening discount link? Is it safe to open a mobile account?
- [MySQL learning notes 23] index optimization
- Which securities company is the largest and safest? How to open an account is the safest
- Could you tell me whether the batch addition of Oracle such as insert all was not blocked?
- 名创优品通过上市聆讯:寻求双重主要上市 年营收91亿
- 币圈大地震:去年赚100万,今年亏500万
- Angers medical sprint scientific innovation board: annual revenue of RMB 300million and proposed fund raising of RMB 770million
- R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图、将两个可视的组合结果对齐
- 老板嘱咐了三遍:低调、低调、低调
猜你喜欢

The hidden crisis of Weilai: past, present and future

Vscode writes markdown file and generates pdf

3. Caller 服务调用 - dapr
![[spatial & single cellomics] phase 1: Study on PDAC tumor microenvironment by single cell binding spatial transcriptome](/img/c4/c053ec830a05f22cab7f7381f9f2b3.png)
[spatial & single cellomics] phase 1: Study on PDAC tumor microenvironment by single cell binding spatial transcriptome

第四大运营商,难成「鲶鱼」

新零售线下店逆势起飞,通膨乌云下的消费热情

环保产品“绿色溢价”高?低碳生活方式离人们还有多远

【黑马早报】腾讯回应大批用户QQ号被盗;薇娅丈夫公司被罚19万;中国恒大被申请清盘;关晓彤奶茶店回应被加盟商起诉...

【算法篇】刷了两道大厂面试题,含泪 ”重学数组“

【mysql学习笔记23】索引优化
随机推荐
Leetcode(665)——非递减数列
ORACLE中dbms_output.put_line输出问题的解决过程
从五大能力到 “1+5+N”,华为让政企转型更稳健
Rails advanced -- framework theory cognition and construction scheme construction (I)
代码片段
Le patron a donné trois ordres: discret, discret, discret
Q-tester 3.2: applicable to development, production and after-sales diagnostic test software
MySQL主从切换的超详细步骤
R语言ggplot2可视化:使用patchwork包将两个ggplot2可视化结果纵向堆叠起来(stacking)形成组合图、一个可视化结果堆叠在另外一个可视化结果上
Successful cases of rights protection of open source projects: successful rights protection of SPuG open source operation and maintenance platform
云杉网络DeepFlow帮助5G核心网和电信云构建可观测性
2022年最新PyCharm激活破解码永久_详细安装教程(适用多版本)
当下不做元宇宙,就像20年前没买房!
dolphinscheduler2. Installation of X (valid for personal test)
浪潮网络步步为赢
论文解读(GCC)《Efficient Graph Convolution for Joint Node RepresentationLearning and Clustering》
老板囑咐了三遍:低調、低調、低調
QQ被盗号后群发黄图,大批用户“社死”
力扣今日题-522. 最长特殊序列
Oracle11g数据库使用expdp每周进行数据备份并上传到备份服务器