Solved

# Batch file - DNS debugging log Backup

Posted on 2014-07-17
596 Views
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
0
Question by:Premkumar Yogeswaran

LVL 4

Accepted Solution

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

LVL 17

Author Comment

We dont have powershell in our domain controllers. Its 2003 servers.
Please could you check for batch file or script.

Thanks,
0

LVL 4

Expert Comment

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

LVL 17

Author Comment

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

LVL 4

Expert Comment

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

LVL 17

Author Comment

We have planned to install powershell in Domain Controllers. will install and update you..
0

LVL 17

Author Comment

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

LVL 17

Author Comment

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

## Featured Post

### Suggested Solutions

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.