增量档案备份批处理脚本
我在 Windows 上有一个 Oracle 存档文件夹,我需要每天早上 6:00 对其进行增量备份。 我需要复制前一天生成的所有文件,并将它们放在具有今天日期的文件夹中。 需要的是,仅复制上次备份后生成的文件[即,文件名的顺序在昨天备份的最后一个文件之后]。 我尝试了 xcopy,但它没有提供任何根据修改时间复制文件的功能。 我需要为此编写一个批处理脚本,请帮助我!
I have an Oracle archives folder on windows, which I need to take an incremental backup everyday at 6:00AM.
I need to copy all the files generated during the previous day, and place them in a folder with today's date.
What is needed is that, the files generated after the last backup was taken, only should be copied [i.e, the file names with the sequence after yesterday's backup's last file].
I tried xcopy, but it doesn't provide any facility for copying files based on modified time.
I need to write a batch script for this, please help me out!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
xcopy
提供了基于存档属性复制文件的方法。您可能需要的选项是/M
,它仅复制具有存档属性集的文件,并重置该属性。它有点依赖于设置的 Archive 属性,但 Windows 在创建或修改文件时默认这样做(我认为)。例如(一个垃圾示例,但仍然是一个示例):
仅复制自上次副本以来新增/修改的文件。
或者,根据您的 Windows 版本,您可以研究更强大的(因此更令人困惑)
robocopy
。xcopy
provides methods for copying files based on their Archive attribute. The option you would likely want is/M
, which copies only files with the Archive attribute set, and resets that attribute. It kind of relies upon the Archive attribute being set, but Windows does this by default (I think) when creating or modifying a file.For example (a rubbish example, but an example nonetheless):
Only files that are new/modified since the last copy are copied.
Alternatively, depending on your Windows version, you could look into the much more powerful (and hence more confusing)
robocopy
.除非数据库关闭,否则如果尝试备份磁盘上的原始文件,可能会出现数据不一致问题。
O'Reilly 的标题是关于所有备份的一个非常好的参考:备份和备份恢复
每个数据库都有自己的在数据库处于活动状态时运行备份的方法。 这是 Oracle 的页面。
Unless the database is shutdown, you can have data inconsistency problems if you attempt to backup the raw files on the disk.
A really great reference for all things backup is an O'Reilly title: Backup & Recovery
Each database will have it's own methods of running backups while the database is live. Here's Oracle's page.