# Batch file - DNS debugging log Backup

We have enabled dns debugging logs with 500 MB, now i have increased the value to maximum limit of 1 GB.
Here issue is the file gets overwritten once it reach the 1 GB limit.
We have a requirement to have the Backup for 7 days, which will have for Sunday to Saturday.

I want the DNsLog file to be copied to an location once it reaches a limit with Day Date &amp;amp; time.

And files more than 7 days has to be deleted.

Please advices some good ideas and help me for the batch file to achive this target.

Thanks,
Prem
LVL 17
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sr. MS SQL DBA and Technical Account ManagerCommented:
Why not use powershell?
Only question - if you delete the file, will the new one be created?
If yes - here's something you can do (run it every X minutes, depends on your file growth tempo)

$dnslog = "C:\Path\To\Your\Log.log"$backuppath = "\\path\to\backup\share\"
$filename = "DNSbackup_" + (Get-Date -UFormat "%Y_%m_%d_%H%M%S").ToString() if ((Get-Item$dnslog).length -gt 900mb) {
Move-Item $dnslog -Destination$filename -Force
}


There might be some syntax errors, but you got the whole idea?
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Analyst II - System AdministratorAuthor Commented:
We dont have powershell in our domain controllers. Its 2003 servers.
Please could you check for batch file or script.

Thanks,
0
Sr. MS SQL DBA and Technical Account ManagerCommented:
I'm sorry, but what's the problem in installing PowerShell?
It's included into all the latest Windows Updates.
I recommend to keep your systems up-to-date.

You need to have Server 2003 SP2.

0
Analyst II - System AdministratorAuthor Commented:
Hi philip,
Thanks for your suggestion. I will check to have PowerShell installed. But still it will take process for approval and change management.

So, we would currently check for Batch Scripting. So we can configure a scheduled task to check the same in timely manner.

Thanks,
0
Sr. MS SQL DBA and Technical Account ManagerCommented:
Unfortunately I'm very bad with VBS, but you have the PowerShell example, so you can easily convert. Just use robocopy instead of Move-Item.
0
Analyst II - System AdministratorAuthor Commented:
We have planned to install powershell in Domain Controllers. will install and update you..
0
Analyst II - System AdministratorAuthor Commented:
Hi Philip,

I have installed powershell in servers. Now before checking your script, we need to decide the scheduled task time interval.

For that, i need to check the file size increasing time frame.

Could you help me to provide a script which will give the output in an notepad and it has to be appended.

Output Format:
Date / Time   | File Path    | File Size in MB

Thanks
0
Analyst II - System AdministratorAuthor Commented:
Hi Philip,

i have created an scheduled task for 15 mins and it is running good...
here it is copying 6 files per day, which is 6 GB per day.

Could you help in another script for the same task for the scenario below

DNSbackup_2014_07_28_143100.log -> this is the log file generated by the script.
i need to filter 5 days old files based on the file name (DNSbackup_*) in that folder and delete those files.

Thanks,
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DNS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.