当前位置:网站首页> Oracle11g数据库使用expdp每周进行数据备份并上传到备份服务器
Oracle11g数据库使用expdp每周进行数据备份并上传到备份服务器
2022-06-28 15:01:00 【1024问】
1.看看数据库情况
1.1先看了下表空间情况,生产环境表空间大概90G,用了才一半不到
2.数据库备份
2.1登陆数据库
2.2创建逻辑目录
2.3给数据库用户文件操作权限#dbuser为数据库用户名,更具实际情况更改
2.3创建物理目录
1.3备份数据库
3.shell脚本实现自动备份
4.添加定时任务
4.参考文章
学校需要将之前的生产数据库备份到华为云,之后实现每周自动备份
1.看看数据库情况1.1先看了下表空间情况,生产环境表空间大概90G,用了才一半不到查看所有表空间及使用情况
SELECT B.FILE_NAME 物理文件名, B.TABLESPACE_NAME 表空间名称, B.BYTES/1024/1024 大小M, (B.BYTES-SUM(NVL(A.BYTES,0)))/1024/1024 已使用M, SUBSTR((B.BYTES-SUM(NVL(A.BYTES,0)))/(B.BYTES)*100,1,5) 使用率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创建逻辑目录执行这个操作并不会在Linux中创建/opt/data_backup这个文件,最后需要手动去创建该文件才能进行备份。
SQL> create directory back_dir as '/opt/backup'SQL> select * from dba_directories; #查看所有逻辑目录,看是否创建成功2.3给数据库用户文件操作权限#dbuser为数据库用户名,更具实际情况更改Grant read,write on directory back_dir to dbuser;2.3创建物理目录[[email protected]]$ mkdir -p /opt/backup #-p 确保目录名称存在,不存在的就建一个,可使用参数创建多级目录1.3备份数据库[[email protected]]$ expdp dbuser/[email protected]:1521/orcl dumpfile=dbback.dmp log=log.log directory=back_dir schemas=cbyxyexedp有很多参数,这里是用到的一些解释
dbuser/[email protected]:1521/orcl #导出用户名/密码@数据库IP/数据库SID
dumpfile=导出的文件名.dmp
log=导出过程的日志名.log
directory=备份放的路径名,用的之前的逻辑目录名
schemas=要备份的数据库用户名字
FULL=y #加上意思为导出整个数据库就不需要schemas参数了
也可以按表空间导出TABLESPACES=
表名导出TABLES=
等等还有很多参数自行了解
#!/bin/bash#导入环境变量,根据具自己实际情况填写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/ #备份服务器的用户,ip,保存地址export ORACLE_USER_NAME=system #数据库的用户密码根据实际情况填写,备份整个库最好使用system或sys管理员用户export ORACLE_USER_PASSWD=Abc123556..export ORACLE_SID=orcl #不知道可以使用Oracle用户执行echo $ORACLE_SID,或者SQL> SELECT instance_name FROM v$instanceexport DATA_DIR=/opt/backup #与数据库中的逻辑地址相同,用来储存备份文件export DELTIME=`date -d "7 days ago" +%Y%m%d` # -d "7 days ago" 为获取七天前的日期,以日期命名方便任务自动删>除export BAKUPTIME=`date +%Y%m%d` #备份日期年月日export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #定义语言地域和字符集属性的环境变量,根据自己数据库情况修改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:指定绝对路径 --remove-files :打包后删除原文件echo "tar the file backup successfully"echo "scp to":$BACKUP_IPscp $DATA_DIR/$BAKUPTIME.tar.gz $BACKUP_USER_IP_DIR #远程服务器防火墙有限制scp端口需要加:-P 端口号rm -f $DATA_DIR/$DELTIME.log #删除之前的备份echo "Bakup completed."
[[email protected] ]$ crontab -e添加行:* 1 * * 6 /opt/back.sh #每个星期的星期六早上执行备份任务
* * * * *- - - - -| | | | || | | | +----- 星期中星期几 (0 - 6) (星期天 为0)| | | +---------- 月份 (1 - 12) | | +--------------- 一个月中的第几天 (1 - 31)| +-------------------- 小时 (0 - 23)+------------------------- 分钟 (0 - 59)4.参考文章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
到此这篇关于Oracle 11g数据库使用expdp每周进行数据备份并上传到备份服务器的文章就介绍到这了,更多相关Oracle 11g使用expdp备份数据内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- Leetcode(406)——根据身高重建队列
- R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用回归系数及其标准误计算每个系数对应的Z统计量的值
- Leetcode(665)——非递减数列
- 2022 operation of simulation test platform for 100 simulated questions of main principals of metal and nonmetal mines (underground mines)
- Talking from the little nematode -- tracing the evolution of nervous system and starting life simulation
- 使用LamdbaUpdateWrapper的setSql作用及风险
- Leetcode (406) - rebuild the queue based on height
- R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图、将两个可视的组合结果对齐
- Differences between ram ROM flash
- The boss told me three times: low key, low key, low key
猜你喜欢

Leetcode 48. Rotate image (yes, resolved)

Softing epgate Pb series Gateway - integrates the Profibus bus into the ethernet/ip network

安杰思医学冲刺科创板:年营收3亿 拟募资7.7亿

Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder

物联网低代码平台常用《组件介绍》

Softing epGate PB系列网关-可将PROFIBUS总线集成到EtherNet/IP网络

Q-Tester 3.2:适用于开发、生产和售后的诊断测试软件

运行近20年,基于Win 98的火星探测器软件迎来首次升级

After nearly 20 years of operation, the Mars probe software based on win 98 has been upgraded for the first time

Is PMP really useful?
随机推荐
The time schedule for the soft test in the second half of 2022 has been determined!
Ionq and Ge research confirmed that quantum computing has great potential in risk aggregation
Seata数据库中出现以下问题要怎么解决呀?
Send2vec tutorial
10 key points to effectively improve performance interview
考了这个PMP证书到底有什么好处?
哪个证券公司最大最安全 怎么办理开户最安全
Quantum frontier hero spectrum - "light quantum Explorer" McMahon: turning any physical system into a neural network
spacy教程(持续更新ing...)
[MySQL learning notes 23] index optimization
2022 recurrent training question bank and online simulation examination for safety inspection of metal and nonmetal mines (underground mines)
dolphinscheduler2.X的安装(亲测有效)
Angers medical sprint scientific innovation board: annual revenue of RMB 300million and proposed fund raising of RMB 770million
解决Unable to create process using ‘D:\Program File
Leetcode (88) -- merge two ordered arrays
How does Seata server 1.5.0 support mysql8.0?
老板囑咐了三遍:低調、低調、低調
Seata数据库中出现以下问题要怎么解决啊?
Leetcode(665)——非递减数列
[spatial & single cellomics] phase 1: Study on PDAC tumor microenvironment by single cell binding spatial transcriptome