物理备份时是否可以忽略某些表空间

发布于 2024-12-21 11:56:01 字数 152 浏览 0 评论 0原文

我们有一个 shell 脚本来执行 Oracle 数据库的物理备份(所有数据库文件的 tar + 压缩)。最近,我们创建了一个表空间,其中包含我们不需要备份其内容的表。

是否可以忽略与此表空间相关的数据文件并拥有有效的备份?

PS:我们不想使用 RMAN。

We have a shell script that perform a physical backup of our oracle database (tar + compress of all our database files). Recently, we created a tablespace containing tables that we dont need to backup its contents.

Is it possible to ignore data files relative to this tablespace and have a valid backup?

PS: we don't want to use RMAN.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

归属感 2024-12-28 11:56:01

我在此先注释一下:这不是规范模式。通常,我们使用RMAN来备份数据库中的所有数据文件。话虽如此...


是的,可以使用 am ssing 数据文件从备份中恢复和恢复数据库。但恢复要求在数据库恢复时删除表空间。

对于删除包含单个数据文件的表空间的简单情况:首先恢复数据库文件,然后:


 STARTUP NOMOUNT;

 ALTER DATABASE MOUNT ;

 ALTER DATABASE DATAFILE '<complete_path_to_datafile>' OFFLINE DROP ;

 ALTER DATABASE OPEN ;

 DROP TABLESPACE <tablespace_name> INCLUDING CONTENTS ;

然后,继续数据库恢复(RECOVER DATABASE;)

显然,您在 DROP TABLESPACE 命令中提供的 tablespace_name 将是相关的到被删除的数据文件。

显然,这对于 SYSTEM 表空间不起作用。我不敢在其他表空间上尝试这个,比如UNDO、SYSAUX、USERS。删除和添加临时表空间的语法也不同。

我不知道“DROP TABLESPACE ... INCLUDING CONTENTS”有任何“陷阱”,但请考虑其他表空间中的对象可能会受到影响。 (考虑到删除的表空间可能具有其他表空间中表的索引、对外键约束的影响、对存储过程的影响等等。)

不言而喻,您需要测试 在生产中依赖此技术之前,在测试环境中执行此类恢复过程。

如果不进行测试,使用 RMAN 来备份所有数据文件会获得更好的服务。


注意:自 Oracle 8 以来,我还没有做过类似的事情,可能是 Oracle 7.3(当时我们必须滚动自己的热备份脚本)。自从我们开始使用 RMAN 以来,我就不需要测试这样的东西了。

注意:可能需要在 ALTER DATABASE OPEN 之前运行 RECOVER DATABASE。我认为您可能会收到有关“数据文件需要更多恢复”的异常警告,就像当表空间处于开始备份模式时启动数据库时所做的那样......

I preface my remarks here with a note: this is NOT the normative pattern. Normally, we use RMAN to backup ALL the datafiles in the database. With that said...


Yes, it may be possible to restore and recover the database from a backup with a m ssing datafile. But the recovery will require that the tablespace be dropped when the database is restored.

For the simple case of a dropping a tablespace that contains a single datafile: first restore the database files, then:


 STARTUP NOMOUNT;

 ALTER DATABASE MOUNT ;

 ALTER DATABASE DATAFILE '<complete_path_to_datafile>' OFFLINE DROP ;

 ALTER DATABASE OPEN ;

 DROP TABLESPACE <tablespace_name> INCLUDING CONTENTS ;

Then, continue with database recovery ( RECOVER DATABASE ; )

Obviously, the tablespace_name you provide in the DROP TABLESPACE command would be the one related to the datafile that is dropped.

Obviously, this wouldn't work for the SYSTEM tablespace. And I wouldn't dare try this on other tablespaces like UNDO, SYSAUX, USERS. And there's different syntax for dropping and adding TEMPORARY TABLESPACES.

I don't know of any "gotchas" with the 'DROP TABLESPACE ... INCLUDING CONTENTS', but consider that objects in other tablespaces could be impacted. (Consider that the dropped tablespace might have indexes for tables in other tablespaces, impacts on foreign key constraints, impacts on stored procedures, and so on.)

And it goes without saying, that you would need to test this type of restore procedure in a test environment before you rely on this technique in production.

Without testing, you would be much better served by using RMAN to backup ALL of the datafiles.


NOTE: I have not done anything like this since Oracle 8, possibly Oracle 7.3 (back when we had to roll our own hotbackup scripts). Since we've started using RMAN, I haven't had a need to test anything like this.

NOTE: The RECOVER DATABASE may need to be run before the ALTER DATABASE OPEN. I think you may get an exception warning about "datafile needing more recovery", like you do when you start the database when a tablespace has been left in BEGIN BACKUP mode...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文