简体   繁体   中英

Incremental archives backup batch script

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 [ie, 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!

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):

C:\tmp>echo hello > out.txt

C:\tmp>xcopy /M *.* ..
C:out.txt
1 File(s) copied

C:\tmp>xcopy /M *.* ..
0 File(s) copied

C:\tmp>echo hello > out2.txt

C:\tmp>xcopy /M *.* ..
C:out2.txt
1 File(s) copied

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM