首页 > 数据库 >OCP-043之:数据库备份操作

OCP-043之:数据库备份操作

时间:2024-06-16 14:32:59浏览次数:37  
标签:22 backup 备份 oracle OCP DISK 043 app u01

1 RMAN备份操作

1.1 基本操作

基本的控制和数据文件备份

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/backup/cs_%F';

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/backup/cs_%F';
new RMAN configuration parameters are successfully stored

RMAN> backup database format '/tmp/backup/fulldb_%u%p%s.bak';

Starting backup at 05-DEC-22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1144 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/tbs01_001.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/users01.dbf
input datafile file number=00002 name=/u01/app/oracle/tbs003.dbf
channel ORA_DISK_1: starting piece 1 at 05-DEC-22
channel ORA_DISK_1: finished piece 1 at 05-DEC-22
piece handle=/tmp/backup/fulldb_061ek4g616.bak tag=TAG20221205T112454 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 05-DEC-22

Starting Control File and SPFILE Autobackup at 05-DEC-22
piece handle=/tmp/backup/cs_c-1648706630-20221205-00 comment=NONE
Finished Control File and SPFILE Autobackup at 05-DEC-22
[oracle@ora-server ~]$ ll /tmp/backup/
total 1229088
-rw-r----- 1 oracle oinstall   10698752 Dec  5 11:25 cs_c-1648706630-20221205-00
-rw-r----- 1 oracle oinstall 1247887360 Dec  5 11:25 fulldb_061ek4g616.bak

列出所有备份

RMAN> list backup;

using target database control file instead of recovery catalog

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    10.19M     DISK        00:00:00     17-NOV-22      
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20221117T144309
        Piece Name: /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_17/o1_mf_s_1121006589_kqdgmfvj_.bkp
  SPFILE Included: Modification time: 17-NOV-22
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 1539134      Ckp time: 17-NOV-22

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    10.19M     DISK        00:00:00     19-NOV-22      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20221119T160124
        Piece Name: /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_19/o1_mf_s_1121184084_kqkvy4dr_.bkp
  SPFILE Included: Modification time: 19-NOV-22
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 1846775      Ckp time: 19-NOV-22

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    10.19M     DISK        00:00:01     29-NOV-22      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20221129T162704
        Piece Name: /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_29/o1_mf_s_1122049624_krd968y9_.bkp
  SPFILE Included: Modification time: 29-NOV-22
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 2743706      Ckp time: 29-NOV-22

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4       Full    10.19M     DISK        00:00:00     29-NOV-22      
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20221129T164706
        Piece Name: /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_29/o1_mf_s_1122050826_krdbctkg_.bkp
  SPFILE Included: Modification time: 29-NOV-22
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 2746266      Ckp time: 29-NOV-22

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5       Full    10.19M     DISK        00:00:00     02-DEC-22      
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20221202T152315
        Piece Name: /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_12_02/o1_mf_s_1122390640_krn2lmbv_.bkp
  SPFILE Included: Modification time: 02-DEC-22
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 2869406      Ckp time: 02-DEC-22

--以上是达到触发条件后,控制文件的自动备份--

--以下是手动备份的数据文件--

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6       Full    1.16G      DISK        00:00:09     05-DEC-22      
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20221205T112454
        Piece Name: /tmp/backup/fulldb_061ek4g616.bak
  List of Datafiles in backup set 6
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
  1       Full 3116228    05-DEC-22              NO    /u01/app/oracle/oradata/orcl/system01.dbf
  2       Full 3116228    05-DEC-22              NO    /u01/app/oracle/tbs003.dbf
  3       Full 3116228    05-DEC-22              NO    /u01/app/oracle/oradata/orcl/sysaux01.dbf
  4       Full 3116228    05-DEC-22              NO    /u01/app/oracle/oradata/orcl/undotbs01.dbf
  5       Full 3116228    05-DEC-22              NO    /u01/app/oracle/oradata/orcl/tbs01_001.dbf
  7       Full 3116228    05-DEC-22              NO    /u01/app/oracle/oradata/orcl/users01.dbf

--以下是手动备份的控制文件和参数文件--

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    10.19M     DISK        00:00:00     05-DEC-22      
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20221205T112509
        Piece Name: /tmp/backup/cs_c-1648706630-20221205-00
  SPFILE Included: Modification time: 05-DEC-22
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 3116239      Ckp time: 05-DEC-22

删除所有备份文件

RMAN> delete backup;

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1       1       1   1   AVAILABLE   DISK        /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_17/o1_mf_s_1121006589_kqdgmfvj_.bkp
2       2       1   1   AVAILABLE   DISK        /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_19/o1_mf_s_1121184084_kqkvy4dr_.bkp
3       3       1   1   AVAILABLE   DISK        /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_29/o1_mf_s_1122049624_krd968y9_.bkp
4       4       1   1   AVAILABLE   DISK        /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_29/o1_mf_s_1122050826_krdbctkg_.bkp
5       5       1   1   AVAILABLE   DISK        /u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_12_02/o1_mf_s_1122390640_krn2lmbv_.bkp
6       6       1   1   AVAILABLE   DISK        /tmp/backup/fulldb_061ek4g616.bak
7       7       1   1   AVAILABLE   DISK        /tmp/backup/cs_c-1648706630-20221205-00

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_17/o1_mf_s_1121006589_kqdgmfvj_.bkp RECID=1 STAMP=1121006589
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_19/o1_mf_s_1121184084_kqkvy4dr_.bkp RECID=2 STAMP=1121184084
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_29/o1_mf_s_1122049624_krd968y9_.bkp RECID=3 STAMP=1122049624
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_11_29/o1_mf_s_1122050826_krdbctkg_.bkp RECID=4 STAMP=1122050826
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/orcl/ORCL/autobackup/2022_12_02/o1_mf_s_1122390640_krn2lmbv_.bkp RECID=5 STAMP=1122391395
deleted backup piece
backup piece handle=/tmp/backup/fulldb_061ek4g616.bak RECID=6 STAMP=1122636294
deleted backup piece
backup piece handle=/tmp/backup/cs_c-1648706630-20221205-00 RECID=7 STAMP=1122636309
Deleted 7 objects

查看系统认为需要备份的文件

RMAN> report need backup;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
1    0     /u01/app/oracle/oradata/orcl/system01.dbf
2    0     /u01/app/oracle/tbs003.dbf
3    0     /u01/app/oracle/oradata/orcl/sysaux01.dbf
4    0     /u01/app/oracle/oradata/orcl/undotbs01.dbf
5    0     /u01/app/oracle/oradata/orcl/tbs01_001.dbf
7    0     /u01/app/oracle/oradata/orcl/users01.dbf

备份1号文件

RMAN> backup datafile 1;

Starting backup at 05-DEC-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: starting piece 1 at 05-DEC-22
channel ORA_DISK_1: finished piece 1 at 05-DEC-22
piece handle=/u01/app/oracle/fast_recovery_area/orcl/ORCL/backupset/2022_12_05/o1_mf_nnndf_TAG20221205T114001_krvln1b8_.bkp tag=TAG20221205T114001 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 05-DEC-22

Starting Control File and SPFILE Autobackup at 05-DEC-22
piece handle=/tmp/backup/cs_c-1648706630-20221205-01 comment=NONE
Finished Control File and SPFILE Autobackup at 05-DEC-22

RMAN> report need backup;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups

--由于冗余策略是1,因此备份一次后,可以看到1号文件消失了,意思是已经满足系统的备份条件,不需要备份了--
File #bkps Name
---- ----- -----------------------------------------------------
2    0     /u01/app/oracle/tbs003.dbf
3    0     /u01/app/oracle/oradata/orcl/sysaux01.dbf
4    0     /u01/app/oracle/oradata/orcl/undotbs01.dbf
5    0     /u01/app/oracle/oradata/orcl/tbs01_001.dbf
7    0     /u01/app/oracle/oradata/orcl/users01.dbf

1.2 Backup Sets

不压缩备份

RMAN> backup as backupset format '/tmp/backup/df_%d_%s_%p.set' tablespace users;

Starting backup at 05-DEC-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-DEC-22
channel ORA_DISK_1: finished piece 1 at 05-DEC-22
piece handle=/tmp/backup/df_ORCL_10_1.set tag=TAG20221205T142249 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-DEC-22

Starting Control File and SPFILE Autobackup at 05-DEC-22
piece handle=/tmp/backup/cs_c-1648706630-20221205-02 comment=NONE
Finished Control File and SPFILE Autobackup at 05-DEC-22

压缩备份

RMAN> backup as compressed backupset format '/tmp/backup/df_%d_%s_%p.set' tablespace users;

Starting backup at 05-DEC-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-DEC-22
channel ORA_DISK_1: finished piece 1 at 05-DEC-22
piece handle=/tmp/backup/df_ORCL_12_1.set tag=TAG20221205T142343 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-DEC-22

Starting Control File and SPFILE Autobackup at 05-DEC-22
piece handle=/tmp/backup/cs_c-1648706630-20221205-03 comment=NONE
Finished Control File and SPFILE Autobackup at 05-DEC-22

查看备份

RMAN> list backup of datafile 7;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10      Full    1.04M      DISK        00:00:00     05-DEC-22      
        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20221205T142249
        Piece Name: /tmp/backup/df_ORCL_10_1.set
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
  7       Full 3123074    05-DEC-22              NO    /u01/app/oracle/oradata/orcl/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12      Full    1.02M      DISK        00:00:00     05-DEC-22      
        BP Key: 12   Status: AVAILABLE  Compressed: YES  Tag: TAG20221205T142343
        Piece Name: /tmp/backup/df_ORCL_12_1.set
  List of Datafiles in backup set 12
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
  7       Full 3123206    05-DEC-22              NO    /u01/app/oracle/oradata/orcl/users01.dbf

删除备份:

RMAN> delete backupset 15;				-

标签:22,backup,备份,oracle,OCP,DISK,043,app,u01
From: https://blog.csdn.net/wuxiaobing1234/article/details/139669093

相关文章

  • 2024中育云备份下载专用网址
    说明Introduction如在使用过程中有任何问题,请及时与我取得联系。由于本人写的所有下载器都挂在ezy服务器上,所以说会涉及跨域访问当出现登录问题时,请确保,网址栏中应为http://...,而不是https://...在线专栏登录器http://ezy-sxz.oss-cn-hangzhou.aliyuncs.com/zxzllogin.htm......
  • ghost备份系统/恢复系统
    准备工作准备一个微PE镜像或者一个微PE启动U盘操作步骤我们这里用虚拟机(win10)进行模拟。首先进入到镜像微PE中(微PE镜像制作请参考微PE工具箱制作成ISO镜像-CSDN博客)进入微PE我们先进行微PE镜像的挂载。先右键虚拟机,点击设置点击如图下所示的位置,将微PE镜像挂载上,点击确......
  • P10432 [JOISC 2024 Day1] 滑雪 2
    MyBlogsP10432[JOISC2024Day1]滑雪2感觉是挺好的观察性质题,vp的时候场切了。首先酒店一定是建在最低的某一个点。把高度离散化之后,把点扔到对应的位置。可以发现高度为\(i\)的层的所有点,如果能接上一层的连接器那一定会尽量接上(因为到了下一层它本身也可以贡献一个空......
  • OCP-042之:Oracle实例管理
    2.Oracle实例管理2.1Instance管理Oracle实例(instance)是一组Oracle后台进程和内存结构的集合。后台进程主要包括SMON,PMON,DBWR,CKPT和LGWR等;内存结构包括数据库高速缓冲区、重做日志缓冲区、共享池、大池等组成系统全局区(SGA)的重要组件。实例主要实现对数据库的访......
  • mac 微信、QQ备份到外接硬盘方案(软链接)
    一、微信备份到外接硬盘mac微信备份到外接硬盘方案(软链接)要找到mac版微信的缓存文件很简单。因为它缓存的文件都保存在电脑的【~/Library/Containers/com.tencent.xinWeChat/Data/Library/ApplicationSupport/com.tencent.xinWeChat/2.0b4.0.9】这个路径中。我们只需要......
  • 在Linux中,如何进行备份或归档文件(tar 命令)?
    在Linux中,tar命令是用来打包和压缩文件的常用工具。它可以将多个文件和目录合并成一个单一的归档文件,并且可以选择性地对其进行压缩。以下是使用tar命令进行备份或归档文件的一些基本用法:1.创建归档文件基本命令格式:tar[选项][归档后的文件名][要归档的文件或目录]......
  • windows系统下,每天定时做mysql数据库备份
    一.备份数据库命令 格式化当前日期setTIMESTAMP=%date:~0,4%%date:~5,2%%date:~8,2% 将现在的日期格式化为yyyyMMdd  备份mysql指定数据库mysqldump-uroot-p123456dbname>"E:\DBbackups\mydb_%TIMESTAMP%.sql" -uroot:root是用户名 -p123456:123456是数据库......
  • MySQL逻辑备份
    目录一.mysqldump基本命令:常用选项:示例备份整个数据库 备份多个数据库 备份所有数据库 仅备份数据库结构仅备份特定表添加选项以有效处理锁表问题恢复数据库从逻辑备份文件恢复注意事项二. mysqlpumpmysqlpump 特点基本命令:常用选项:示例备份单个数据库......
  • 蜂窝备份守护,连锁门店数字化业务无忧运转
    1、需求背景连锁商超在多个地理位置运营,依赖互联网进行POS系统、库存管理、客户关系管理等关键业务操作。现代消费者期望快速、无缝的购物和支付体验,网络的中断会导致交易失败,影响顾客满意度和整体运营。门店联网常见的一些挑战如下:网络可靠性无保障任何一个门店的主链路中......
  • 从 Android 恢复已删除的备份录
    本文介绍了几种在Android上恢复丢失和删除的短信的方法。这些方法都不能保证一定成功,但您可能能够恢复一些短信或其中存储的文件。首先要尝试什么首先,尝试保留数据。如果你刚刚删除了信息,请立即将手机置于飞行模式,方法是按住电源按钮并在出现的菜单中选择飞行模式。......