If you need to do rotating daily backups (seven backups), you can use this simple batch code to call ntbackup.exe.
@echo off
for /f "tokens=1-3 delims=. " %%i in ('date /t') do (set day=%%i)
echo Day: %day%
ntbackup backup \\server\share /j "backup %day%" /f "c:\backups\backup.%day%.bak"
This will fill batch variable %day% with current day (two letters) taken from "date /t" command. Then it will call ntbackup to run a full backup of "\\server\share" including all subdirectories (/j) and will store it to "c:\backups\backup.%day%.bak". Variable %day% will be replaced by current day of the week... so this little script will create 7 backups and will rotate them (if you will run it daily using windows scheduler).
This is really simple batch and can be easily modified to do much more.
No comments:
Post a Comment