Jump to content

Copy Batch file


Recommended Posts

Guest spider6986
Posted

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

Posted (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 by BassTech
Guest spider6986
Posted
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

Posted

@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.

Posted
@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 :(

Posted

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.

Posted
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 :nerd:

Guest spider6986
Posted
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 :D

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...