Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NT 4.0: Is there a way to move old files via .bat file?

Status
Not open for further replies.

web4fun

MIS
Oct 2, 2002
127
US
NT 4.0 Server
SQL Server 7.0

Problem:

I am currently running out of disk space on my backup drive (for my SQL backups) which is causing any SQL backups that run more than two days to fail due to insufficient disk space...so what I've been manually doing is copying any .BAK file older than 1 day over to a share that's on a different server.

I have on other Win2K and above servers used a VB Script to move / delete older files however...since the script will not run on NT which didn't surprise me...so, does anyone have any suggestions on how I might be able to get older .BAK files move to a share on an NT4 server? I'm thinking perhaps if I share the VB script from one of my other Win2k/2003 servers and run the script from the share that it might then work.

Yes, this server is due to be replaced soon but in the meantime I needed an temporary work-around.

Thanks.
 
Although in theory you can do this with a batch file, but is there any reason why the script doesn't work on NT? Is it possible because you don't have WSH/VBscript installed (for NT 4 it has to be downloaded)
 
Robocopy (Resource kit util) works with NT 4.0 and will move old files (age defined by user) to another location. It will also purge the moved document on the current server. Robocopy runs in monitor mode so that you don't have to complete to task manually.

Robocopy GUI - Second link under November 2006.



Jesse Hamrick
 
I realize this may be an in-elegant solution, but one network I support runs Sql 7 on and NT SP6a box with Win xp Pro sp2 clients. On a xp client, I use event scheduler to run a daily batch file. Below is the batch file. It creates a folder using the client machine's clock date and then uses a mapped drive to the server backup Sql directory to grab the BAK files, copy to the client HDD and then clean up the server folder. Although not elegant, it runs like a top for me. Robocopy is a super utility, but you need to know your command switches, even with the GUI. U: is the mapped drive to the server SQL back folder. Put the batch file in the c:\client_bkup_folder folder, as it will put the date-named folders it creates in that same folder.

@echo off
rem - - - - - - - - - - - - - - - - - - - - - -
rem - - - - - - - - - - - - - - - - - - - - - -
cd c:\client_bkup_folder

for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set mdate=%%c%%a%%b"-SQL-BACKUP-FILES"
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set MM=%%a
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set DD=%%b
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set YY=%%c
IF %MM:~0,1%==0 SET MM=%MM:~1%
IF %DD:~0,1%==0 SET DD=%DD:~1%
set cdate=%MM%-%DD%-%YY%

@echo on
mkdir %mdate%
cd %mdate%

copy U:\*.bak *.bak
Del U:\*.bak
 
It might also be worth looking into forfiles.exe - you can grab it from Microsoft's download centre I think.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top