Olli1009 Posted March 10, 2005 Share Posted March 10, 2005 Hi guys,Not sure whether i landed in the right forum, but i will try anyway:We have a backup script that runs daily and performs different backup tasks with NtBackup.There is a remote site with a DC in it on which we want to backup the system state+several folders to a local disk.What i need to insert in a script is some sort of "If, then" line, which will delete the old copies of the .bkf files, up to 3 days back. Thus, if a backup was performed on 20-th of the month, i want the script to delete all previos .bkf files and will leave only the last 3 backups, from 17,18,19 of the month.Does anyone have any clue what is the syntax i should use to perform such operation?I'm quite clueless when it comes to scripts .Any help would be highly appreciated,Thanx! Link to comment Share on other sites More sharing options...
DotBet Posted March 10, 2005 Share Posted March 10, 2005 (Note: Post has been editted (updated)Post your current script to see what there is to work with.There are many ways to accomplish the same thing. I would start by naming the backup files by date, or day (1.bkf - 31.bkf etc). Then rename the 3 you want to keep while you delete the rest.One way to do it...A small example:set name=%date:~7,2%ntbackup backup systemstate /j "Command Line Backup 4" /f "c:\backups\%name%.bkf"if %name% == 20 goto _deloldexit:_deloldif exist c:\backups\17.bkf ren c:\backups\17.bkf bkf.17if exist c:\backups\18.bkf ren c:\backups\18.bkf bkf.18if exist c:\backups\19.bkf ren c:\backups\19.bkf bkf.19if exist c:\backups\20.bkf ren c:\backups\20.bkf bkf.20del c:\backups\*.bkfif exist c:\backups\bkf.17 ren c:\backups\bkf.17 old17.bkfif exist c:\backups\bkf.18 ren c:\backups\bkf.18 old18.bkfif exist c:\backups\bkf.19 ren c:\backups\bkf.19 old19.bkfif exist c:\backups\bkf.20 ren c:\backups\bkf.20 old20.bkfexitBy renaming them with the "old" prefix, they will be deleted next month along with all other bkf files, and there will be no overwrite problem with the next months files named 17, 18, 19 .bkf 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