Guest spider6986 Posted February 8, 2010 Posted February 8, 2010 Hey everyone, We have a program here that backs up files every hour and keeps all the backups for the day. We have 7 databases that backup and we need the latest backup for those 7 to be copied into another once a day so we can run a daily backup of them. I am no good at writing Batch files, so was wonderin if someone knew what to type. For example, the files would be backing up to a folder on the E: drive called temp, and the latest backup for the 7 files need to be copied into the folder on E: called daily. Any help appreciated
Michael Posted February 8, 2010 Posted February 8, 2010 @echo off XCOPY e:\temp\*.* e:\daily\ /Y exit Use Scheduled Tasks to schedule the date/time you want this to happen.
BassTech Posted February 8, 2010 Posted February 8, 2010 (edited) We use this script for our VLE backup [edited]: @echo off XCOPY E:\temp\*.* E:\daily\*.* /V /S /H /R /F /Y exit Copy & paste into notepad and save as "backup".bat then go to Start>All Programs>Accessories>System Tools>Scheduled Tasks and set "backup.bat" to run everyday Edited February 8, 2010 by BassTech
Guest spider6986 Posted February 8, 2010 Posted February 8, 2010 We use this script for our VLE backup [edited]: @echo off XCOPY E:\temp\*.* E:\daily\*.* /V /S /H /R /F /Y exit Copy & paste into notepad and save as "backup".bat then go to Start>All Programs>Accessories>System Tools>Scheduled Tasks and set "backup.bat" to run everyday it's copying across everything in that folder at the moment, need the last of those files files are named like this "backup 1 02-05-10 02-50-00PM" "backup 2 02-05-10 02-50-10PM" "backup 3 02-05-10 02-50-15PM" "backup 1 02-05-10 02-40-00PM" etc. What I need is for the batch file to grab the "backup 1 02-05-10 02-50-00PM" "backup 2 02-05-10 02-50-10PM" "backup 3 02-05-10 02-50-15PM" and leave the "backup 1 02-05-10 02-40-00PM" alone
BassTech Posted February 8, 2010 Posted February 8, 2010 That's quite advanced for an xcopy command - Have a read about the /Exclude switch here - The Windows command Xcopy and its uses which you may be able to use with the /D switch maybe?
Michael Posted February 8, 2010 Posted February 8, 2010 @echo off XCOPY e:\temp\backup 1 02-05-10 02-50-00PM.BKF e:\daily\ /Y XCOPY e:\temp\backup 2 02-05-10 02-50-10PM.BKF e:\daily\ /Y XCOPY e:\temp\backup 3 02-05-10 02-50-15PM.BKF e:\daily\ /Y XCOPY e:\temp\backup 1 02-05-10 02-40-00PM.BKF e:\daily\ /Y exit Maybe something like this as the *.* just means everything within that directory.
BassTech Posted February 8, 2010 Posted February 8, 2010 @echo off XCOPY e:\temp\backup 1 02-05-10 02-50-00PM.BKF e:\daily\ /Y XCOPY e:\temp\backup 2 02-05-10 02-50-10PM.BKF e:\daily\ /Y XCOPY e:\temp\backup 3 02-05-10 02-50-15PM.BKF e:\daily\ /Y XCOPY e:\temp\backup 1 02-05-10 02-40-00PM.BKF e:\daily\ /Y exit Maybe something like this as the *.* just means everything within that directory. Wont the file name change every day though? What about this: @echo off XCOPY E:\temp\backup*15PM.* E:\daily\*.* /V /S /H /R /F /Y exit Not sure if that will work
Michael Posted February 8, 2010 Posted February 8, 2010 Yes, good point Lee91. The easiest option would be to backup that one file to 'Temp2' for example, so the *.* command could be used again.
AXE Posted February 8, 2010 Posted February 8, 2010 Run ATTRIB -A "E:\TEMP\BACKUP 1 *" ATTRIB -A "E:\TEMP\BACKUP 2 *" etc. before each hourly backup. After the backup, the only files with the 'archive' attribute set will be the most recent of each backup. Then XCOPY "E:\TEMP\*" "E:\DAILY\" /A /V /Y will only copy files with the 'archive' attribute set.
BassTech Posted February 8, 2010 Posted February 8, 2010 Run ATTRIB -A "E:\TEMP\BACKUP 1 *" ATTRIB -A "E:\TEMP\BACKUP 2 *" etc. before each hourly backup. After the backup, the only files with the 'archive' attribute set will be the most recent of each backup. Then XCOPY "E:\TEMP\*" "E:\DAILY\" /A /V /Y will only copy files with the 'archive' attribute set. Nice, that should work
Guest spider6986 Posted February 8, 2010 Posted February 8, 2010 Run ATTRIB -A "E:\TEMP\BACKUP 1 *" ATTRIB -A "E:\TEMP\BACKUP 2 *" etc. before each hourly backup. After the backup, the only files with the 'archive' attribute set will be the most recent of each backup. Then XCOPY "E:\TEMP\*" "E:\DAILY\" /A /V /Y will only copy files with the 'archive' attribute set. Spot on, thank you very much, you have made me very happy
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now