• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1067

# NTBackup Command line - How to name Backup Dynamically?

I am using NTBackup to do backups of our servers, the problem is I am having to create a new scheduled event anytime I want the backup to have a different file name. For example I have a Monday event to save a <server name>-Monday.bks file. Is there a way to dynamically name the backup files so I can have a single scheduled event doing this?
0
danielevans83
• 3
• 3
1 Solution

Commented:

Not directly on the command line. You'd have to use some script as the scheduled task, which then calls the appropriate NT Backup command line.

See my example below and adapt it as you require.

-Matt

' Save this as a VBS script with a .VBS extension
' Paste in your entire ntbackup command between the quotation marks after objShell.Exec
' Where you wish to place the day name (i.e. Monday) put paste directly at the spot the text indicated
' Command Starts with :    " & WeekdayName(Weekday(Date())) & "
' This will dynamically name the backup files with the weekday name if you paste that code into the part of the command which defines the script name

' Then schedule this script in the Task Scheduler. In the Task use the command   cscript "C:\path\to\script\dynamicbackup.vbs"

' Good luck!
' tigermatt - Experts Exchange - 16 Feb 2009

Set objShell = CreateObject("WScript.Shell")

objShell.Exec "ntbackup ... full command here ... " & WeekdayName(Weekday(Date())) & " ... continue the command ... "

0

Author Commented:
Let's say this is my NTBackup script: Where would I insert the part you described?

C:\WINDOWS\system32\ntbackup.exe backup "@C:\Documents and Settings\553lle\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\Daily Server Backupp.bks" /v:yes /r:no /rs:no /hc:off /m normal /j "Daily Server Backupp" /l:s /f \\XXXsrv02\G$\Monday\LLESRV01.bkf As you can see I'm currently using a folder called Monday, which is dumb. :) 0 Commented: I apologise for not replying sooner. As has been noted in my profile, there has been some sort of issue with the EE alerts notifying me of new comments in a question, so I never received the alert to follow-up on this issue. The below in your VBS script would do the trick.  ' Save this as a VBS script with a .VBS extension ' Paste in your entire ntbackup command between the quotation marks after objShell.Exec ' Where you wish to place the day name (i.e. Monday) put paste directly at the spot the text indicated ' Command Starts with : " & WeekdayName(Weekday(Date())) & " ' This will dynamically name the backup files with the weekday name if you paste that code into the part of the command which defines the script name ' Then schedule this script in the Task Scheduler. In the Task use the command cscript "C:\path\to\script\dynamicbackup.vbs" ' Good luck! ' tigermatt - Experts Exchange - 16 Feb 2009 Set objShell = CreateObject("WScript.Shell") objShell.Exec "C:\WINDOWS\system32\ntbackup.exe backup "@C:\Documents and Settings\553lle\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\Daily Server Backupp.bks" /v:yes /r:no /rs:no /hc:off /m normal /j "Daily Server Backupp" /l:s /f \\XXXsrv02\G$\" & WeekdayName(Weekday(Date())) & "\LLESRV01.bkf"

0

Commented:
The script above is the version of the script you provided, with the name of the day added in. No other changes have been made. Since your question has been answered, points should be awarded.

-Matt
0

Author Commented:
Your script caused problems since after the drive was full of backups it started erroring out. Hence my need to hire a consultant to make a custom script to go through and delete files on the drive before the backup. Again, thanks for trying but just because your solution works for you doesn't mean you solved my problem.
0

Author Commented:
script dynamically names backups successfully. be aware to keep room on backup source for all backups or set up some kind of system to routinely delete older backups.
0

## Featured Post

• 3
• 3
Tackle projects and never again get stuck behind a technical roadblock.