r00ster Posted October 15, 2007 Share Posted October 15, 2007 Hi,I'm looking for a way to automate the copy of a windows backup file (BKF). My server (WIN2K3 SBS) is configured to leave 3 versions of the backup on a external harddisk so I can retrieve files that were previously deleted. I also would like to copy the latest created BKF file to another external harddisk that I can take back home with me so in case of a fire or theft I have an extra copy.The BKF file is large (over 90 Gb) and takes a few hours to be created, this is done every night from 02:00 till 7:00 in the morning. What I would like to accomplish is that during lunch time I click on a vb script that copies the newest BKF file to another external harddisk so that a few hour later I can unplug the harddisk and take it home. Because there are 3 files of over 90 Gb the normal "xcopy *.* f:\" line will take to long to copy all the files to the harddisk.Can somebody help me out with a simple script that will copy only the newest BKF to my external harddisk. Thanks,r00ster Link to comment Share on other sites More sharing options...
phkninja Posted October 15, 2007 Share Posted October 15, 2007 if you already have the 3 files on the disk, then doingxcopy *.* f:\ /DThis will only copy the files that have been changed (it comapres the timestamp of the files then copies the most up to date) Link to comment Share on other sites More sharing options...
r00ster Posted October 15, 2007 Author Share Posted October 15, 2007 Yes, i've tried /d argument..What I forgot to tell is that I sometimes skip a day or two, so then it still copies all the files, so /d will work if I'm able to do it every day (which i'm not ). Link to comment Share on other sites More sharing options...
jaclaz Posted October 15, 2007 Share Posted October 15, 2007 You can easily use this (just copy and paste into a new file newer.cmd):@echo offSETLOCAL ENABLEEXTENSIONSSETLOCAL ENABLEDELAYEDEXPANSIONSet /A Counter=0FOR /F "skip=2 tokens=4" %%A in ('dir %1 /o-D') DO (IF !Counter!==0 ECHO %%ASET Counter=!Counter!+1)use as newer.cmd "drive\Path\directory"this will simply display the filename of the most recent file in the given directory.Just change the %1 in the FOR loop with your hardcoded path (if you wish to do so) and change the ECHO command into your xcopy one.The following is slightly more elaborate but returns more data on the file:@echo offSETLOCAL ENABLEEXTENSIONSSETLOCAL ENABLEDELAYEDEXPANSIONSet /A Counter=0FOR /F "skip=2 tokens=4" %%A in ('dir %1 /o-D') DO (IF !Counter!==0 (ECHO Name : %%~nAECHO Extension: %%~xAECHO Full Path: %%~fA)SET Counter=!Counter!+1)In a command prompt type FOR /? to see other possible expansions of variables.jaclaz Link to comment Share on other sites More sharing options...
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