Editing Scheduled Tasks ntbackup .job files

Solution 1:

I'm having a little trouble parsing you. I think you're talking about Scheduled Task ".JOB" files to fire off NTBACKUP.

Have a look at the SchTasks.EXE tool. It will allow you to script the creation, deletion, modification, etc of Scheduled Tasks on local and remote computers. I'd guess that you can get the functionality you're looking for there.

NTBACKUP uses the Windows BackupFile APIs, so you can get away w/ using an account that is a member of the "BUILTIN\Backup Operators" group. If the PCs are domain members and you're not squeamish about using the same account on all of them, I'd create a domain account and nest it into the "Backup Operators" group on each PC using the "Restricted Groups" functionality of Group Policy. Then, I'd use a startup script to query for and, if not present, deploy a scheduled task with the desired backup parameters onto that computer. The deployment script will need the plaintext password of the backup account in it, so I'd make the startup script readable only by "Domain Computers" (and not "Authenticated Users" as it is by default).

Edit:

I'd just create the task on the remote computer w/ SchTasks.Exe-- I wouldn't bother trying to copy the .JOB files around at all. That's probably asking for trouble, actually.

You could write a startup script that would do something like:

@echo off
SET TASK_NAME=Task name
SET TASK_USER=User_for_task_to_run_under
SET TASK_USER_PW=Password_for_user_to_run_task_under

rem Escape any quotes in the task command with slashes (i.e. \")
SET TASK_CMD=%SystemRoot%\System32\ntbackup.exe backup @Selection_List_Name.bks \"Job Description\" /F C:\Backup_Set.bkf

schtasks /query /fo LIST | find "%TASK_NAME%" >NUL 2>NUL
if errorlevel 1 goto create_task
goto end

:create_task
schtasks /create /RU %TASK_USER% /RP %TASK_USER_PW% /SC WEEKLY /D MON,TUE,WED,THU,FRI /ST 02:00:00 /TN "%TASK_NAME%" /TR "%TASK_CMD%"

:end

That should give you a good start. You'll still want to get your backup selection lists out to the clients (or specify the selections on the NtBackup command line).

re: Adding a user to "Backup Operators" on groups of computers - You should read-up on the "Restricted Groups" functionality in Group Policy. The functionality was originally meant to control the membership of "sensitive" groups, but it's been used frequently to automate group membership. Do some seraching on Microsoft's site for docs and setup a test OU and a test computer to play with it. You'll be glad you did.

Solution 2:

I built a tool a while back that may be useful for you, basically, instead of scheduling a task that points at NTbackup, you schedule a task that runs a python script that consults a XML document that has the backup schedules. The python script determines what to backup, and then runs ntbackup with the configuration described in the document.

The great advantage of this, is that once you have things setup, you can simply adjust the backup selections by editing the xml document you have stored on some central server.

Even if you don't want to use the script, you can use it as an example for how to programatically create the backup selection files (bks). The BKS files are basically just a unicode text file without the BOM.


Updated to address comment

Is there an editor that will let me just edit the bkf file, opening with notepad and doing save as with unicode doesn't seem to cut it, ntbackup just crashes.

I am not aware of any text editors that would work, and I tried several. I hacked together a quick script for that should convert a text file with selections in it to a working bks.