Kaseya Community

Script for system state backup

This question is not answered

Hi Community,

has anyone of you tried to create a system state backup with a script? 

Regards Richard

All Replies
  • I have and it works like a champ. I set it as a pre procedure before acronis runs it backup. I have attached the script below.

    _________________________________________________________________

    <?xml version="1.0" encoding="utf-8"?>

    <ScriptExport xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="www.kaseya.com/.../Scripting">

     <Procedure name="NTBackup SystemState" treePres="3" id="1511803971">

       <Body description="Backups up the System State using NT Backup. Windows 2000 and 2003 server. Saves file to C:\folder\systemstate\backup.bkf">

         <If description="Tests to see if Systestate folder exists.">

           <Condition name="TestFile">

             <Parameter xsi:type="StringParameter" name="Path" value="C:\folder\SystemState\null" />

             <Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />

             <Parameter xsi:type="StringParameter" name="Value" value="" />

           </Condition>

           <Then>

             <Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">

               <Parameter xsi:type="StringParameter" name="Comment" value="Folder is present" />

             </Statement>

             <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="true" osType="2003">

               <Parameter xsi:type="StringParameter" name="Command" value="ntbackup backup systemstate /J "Backup Job 1" /l:f /f "C:\folder\Systemstate\backup.bkf"" />

               <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />

               <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />

             </Statement>

           </Then>

           <Else>

             <Statement description="Write the selected directory, subdirectories and files to the machine at the path specified." name="WriteDirectory" continueOnFail="false" osType="Windows">

               <Parameter xsi:type="StringParameter" name="Path" value="C:\folder\SystemState" />

               <Parameter xsi:type="StringParameter" name="SourceDirectory" value="Kathy\" />

             </Statement>

             <Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">

               <Parameter xsi:type="StringParameter" name="Comment" value="SystemState folder was created." />

             </Statement>

             <Statement description="Runs ntbackup  through command line." name="ExecuteShellCommand" continueOnFail="false" osType="2003">

               <Parameter xsi:type="StringParameter" name="Command" value="ntbackup backup systemstate /J "Backup Job1"/l:f /f "C:\folder\Systemstate\backup.bkf"" />

               <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />

               <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />

             </Statement>

           </Else>

         </If>

         <Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">

           <Parameter xsi:type="StringParameter" name="Comment" value="Syste State backup completed" />

         </Statement>

       </Body>

     </Procedure>

    </ScriptExport>

  • Hi Richard,

    There are a a couple of command line options you have for backing up the system state of a Windows system.   If the machine is Windows Server 2003 R2 or below then you can use NTBACKUP, and if the machine is Windows Server 2008/2008 R2 then you can use WBADMIN.

    NTBACKUP example...

    Using a series of Get Variable steps...

      Create a variable called agentid and set it to the machineid.groupid.

      Create a variable called bvol and set it to the constant value representing the volume to use in the backup destination path (i.e. drive letter).

      Create a variable called bkfname and set it to the subpath and filename of the destination backup file.

    Use an Execute Shell Command or Execute File step with the following command...

      ntbackup backup systemstate /v:yes /r:no /rs:no /hc:off /m normal /j “#agentid# system state backup” /l:f /f “#bvol#\#bkfname#”

    WBADMIN example...

    Using a Get Variable step...

      Create a variable called bvol and set it to the constant value representing the volume to use in the backup destination path (i.e. drive letter).

    Use an Execute Shell Command or Execute File step with the following command...

      wbadmin start systemstatebackup -backupTarget:#bvol# -quiet

    Note: The Windows Backup Feature (including Backup Command Line Tools) needs to be installed on the Windows 2008 server prior to using WBADMIN.  To install it from and command line you can use another command line tool and a couple additional steps/checks...

    Using a Get Variable step...

      Create a variable called awrk and set it to the value of the Agent Working Directory.

    Use an Execute Shell Command or Execute File stepwith the following command...

      servermanagercmd -query>>#awrk#\srv2008rf.txt

    Using an IF step with a check to...

      Test File #awrk#\srv2008rf.txt to see if it...

           Does Not Contain...

               [X] Command-line Tools  [Backup-Tools]

      Then

         Use an Execute Shell Command or Execute File stepwith the following command...

            servermanagercmd -install Backup-Tools

    I hope this helps get you pointed in the right direction.

    Regards,

    Matt Warburton

    Kaseya Professional Services

  • Hi kpedraza ,

    There seems to be a syntax error in this line in your script:

    <Parameter xsi:type="StringParameter" name="Command" value="ntbackup backup systemstate /J "Backup Job 1" /l:f /f "C:\folder\Systemstate\backup.bkf"" />

  • www.microsoft.com/.../ntbackup_backup_sysstate.mspx

  • Hi, thanks a lot for the feedback ...

    Now I have already worked a little bit with wbadmin and it works perfect!

    Question: How can I find out whats the volume with the most free space and how can i but this information in a variable? With this information I can always save the systemstate backup on a volume with the most free space ....

    Richard

  • It works fine by just rearranging the quotation marks:

    <Parameter xsi:type="StringParameter" name="Command" value="ntbackup backup systemstate /J Backup Job 1 /l:f /f C:\folder\Systemstate\backup.bkf" />