Tivoli Storage Manager and SQL backup

The script that was used as a template for initiating the SQL backup from the TDP agent is simply a bat-file. It isn’t very complicated and quite basic. Since deploying this backup within a datacenter and dealing with a few different SQL-servers installed in quite a few different ways – it seemed that this script had as many variations as we had SQL-servers installed. The main flaws were around the fact that multiple SQL instances weren’t detected and that the transaction-log weren’t truncated when the backup had been run for databases that were set to recovery mode FULL. Inorder to make this more manageable the following improvements were made;

  • Detect all SQL instances via the local the registry – based on Jay’s blog
  • Exclude Windows Internal Databases
  • Run through all databases in each instance. Verify if there are any offline instances and databases
  • Backup all databases or each database that are online.
  • Run a backup of transaction log and truncate it – some things based on SpaghettiDBA
  • Track all errors and exit the command with the error if one occurs to allow TSM to report a failed backup

It does not;

  • Detect if a SQL instance is offline
  • Detect if SQL is not installed and then fail

Why a bat-file?
All servers we are supporting doesn’t have Powershell. A reality…

@ECHO OFF

rem ==================================================================

rem sqlfull.smp sample command file

rem

rem Sample command file containing commands to do a scheduled full

rem backup of all SQL databases to an IBM Tivoli Storage Manager

rem server.

rem

rem This file is meant to be executed by the IBM Tivoli Storage

rem Manager central scheduler in response to a defined schedule on

rem the IBM Tivoli Storage Manager server.

rem

rem ==================================================================

rem ==================================================================

rem Replace "C:" with the drive where Data Protection for SQL

rem is installed. Update the directory to match the installation

rem directory that you chose when you installed the product.

rem ==================================================================

set TSMERROR=0

set sql_dir=C:\Progra~1\Tivoli\TSM\TDPSql

C:

cd %sql_dir%

rem ==================================================================

rem The two lines below put a date/time stamp in a log file for you.

rem Note: You can change "sqlsched.log" to whatever you prefer in

rem lines below.

rem ==================================================================

date < NUL >> %sql_dir%\sqlsched.log

time < NUL >> %sql_dir%\sqlsched.log

rem ==================================================================

rem Now call the command-line interface to do the backup:

rem

rem Replace "srvrname" with the name of the options file name you

rem plan to use.

rem

rem If SQL authentication is being used and the SQL login settings have

rem not been stored via the GUI, you must also specify the /sqluser and

rem /sqlpassword options on the command below.

rem

rem In this example, we use the '*' to back up all of the databases

rem on the SQL server. Note that database 'tempdb' will not

rem be backed up.

rem

rem Note: You can change "sqlsched.log" and "sqlfull.log" to

rem whatever you prefer.

rem ==================================================================

rem %sql_dir%\tdpsqlc backup * full /tsmoptfile=%sql_dir%\dsm.opt /logfile=%sql_dir%\sqlfull.log >> %sql_dir%\sqlsched.log

rem ===================================================================

rem Query all Microsoft SQL Server instances installed

rem ==================================================================

ECHO Creating tdpsqlservers.txt > command.log

reg query "HKLM\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL">> tdpsqlservers.txt

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL" >> tdpsqlservers.txt

ECHO Generated tdpsqlservers.txt >> command.log

FOR /F "tokens=1 delims= " %%B IN (tdpsqlservers.txt) DO IF NOT "%%B"=="HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft" IF NOT "%%B"=="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft" IF NOT "%%B"=="MICROSOFT##SSEE" CALL:servers %%B

del tdpsqlservers.txt

ECHO Deleted tdpsqlservers.txt >> command.log

del tdpsql_input.txt

ECHO Deleted tdpsql_input.txt >> command.log

ECHO Exit code %TSMERROR% >> command.log

exit /b %TSMERROR%

rem ================================================================

rem Verify all database instances

rem Check if there are any offline databases

rem ================================================================

:servers

IF NOT "%1"=="MSSQLSERVER" SET INSTANCE=%COMPUTERNAME%\%1

IF NOT "%1"=="MSSQLSERVER" SC QUERY "MSSQL$%1" | find /i "RUNNING"

IF ERRORLEVEL 1 ECHO %INSTANCE% offline >> command.log | GOTO :EOF

IF "%1"=="MSSQLSERVER" SET INSTANCE=%COMPUTERNAME%

IF "%1"=="MSSQLSERVER" SC QUERY "MSSQLSERVER" | find /i "RUNNING"

IF ERRORLEVEL 1 ECHO %INSTANCE% offline >> command.log

IF ERRORLEVEL 1 GOTO :EOF

ECHO Verify Server %INSTANCE% >> command.log

SQLCMD -S %INSTANCE% -E -Q "SET NOCOUNT ON; SELECT name FROM sys.databases WHERE state_desc IN ('OFFLINE')" -h -1 -o tdpsql_offline.txt

ECHO Generated tdpsql_offline.txt >> command.log

SET FILE=tdpsql_offline.txt

FOR %%R IN (%FILE%) DO (

IF %%~zR LSS 87 (GOTO :backup

) ELSE (GOTO :backupoffline)

)

GOTO :EOF

rem ================================================================

rem Run a backup against each instance without offline dbs

rem For each instance - check what databases have FULL recovery

rem ================================================================

:backup

ECHO Backup all databases >> command.log

CALL %sql_dir%\tdpsqlc backup * full /SQLSERVER=%INSTANCE% /tsmoptfile=%sql_dir%\dsm.opt /logfile=%sql_dir%\sqlfull.log >> %sql_dir%\sqlsched.log

IF NOT "%ERRORLEVEL%"=="0" SET TSMERROR=%ERRORLEVEL%

SQLCMD -S %INSTANCE% -E -Q "SET NOCOUNT ON; SELECT name FROM sys.databases WHERE recovery_model_desc IN ('FULL') AND state_desc IN ('ONLINE')" -W -h -1 -o tdpsql_input.txt

ECHO Generated tdpsql_input.txt >> command.log

FOR /F "delims=" %%A IN (tdpsql_input.txt) DO CALL:translog "%%A"

del tdpsql_offline.txt

ECHO Deleted tdpsql_offline.txt >> command.log

GOTO :EOF

rem ================================================================

rem Run a backup against each instance with offline dbs

rem For each instance - check what databases have FULL recovery

rem ================================================================

:backupoffline

echo Backup - offline DBS located >> command.log

SQLCMD -S %INSTANCE% -E -Q "SET NOCOUNT ON; SELECT name FROM sys.databases WHERE state_desc IN ('ONLINE')" -h -1 -o tdpsql_online.txt

ECHO Generated tdpsql_online.txt >> command.log

FOR /F %%D IN (tdpsql_online.txt) DO CALL:dbbackup %%D

del tdpsql_offline.txt

ECHO Deleted tdpsql_offline.txt >> command.log

del tdpsql_online.txt

ECHO Deleted tdpsql_online.txt >> command.log

SQLCMD -S %INSTANCE% -E -Q "SET NOCOUNT ON; SELECT name FROM sys.databases WHERE recovery_model_desc IN ('FULL') AND state_desc IN ('ONLINE')" -h -1 -o tdpsql_input.txt

FOR /F %%A IN (tdpsql_input.txt) DO CALL:translog %%A

GOTO :EOF

rem ================================================================

rem Run a backup against a specific database

rem ===============================================================

:dbbackup

ECHO Backup against specific database %1 >> command.log

CALL %sql_dir%\tdpsqlc backup %1 full /SQLSERVER=%INSTANCE% /tsmoptfile=%sql_dir%\dsm.opt /logfile=%sql_dir%\sqlfull.log >> %sql_dir%\sqlsched.log

IF NOT "%ERRORLEVEL%"=="0" SET TSMERROR=%ERRORLEVEL%

GOTO :EOF

rem ================================================================

rem Run a log-file backup and truncate the transaction log

rem ===============================================================

:translog

SET DB=%1

ECHO Transaction Log for %DB% >> command.log

CALL %sql_dir%\tdpsqlc backup %1 log /truncate=yes /SQLSERVER=%INSTANCE% /tsmoptfile=%sql_dir%\dsm.opt /logfile=%sql_dir%\sqlfull.log >> %sql_dir%\sqlsched.log

IF NOT "%ERRORLEVEL%"=="0" SET TSMERROR=%ERRORLEVEL%

GOTO :EOF

:EOF

ConfigMgr 2012, App-V and /EXE

Really? Still not supported?
When using the ConfigMgr integration – it takes over the App-V Client and replaces the default startup for all virtualized applications to something other than sfttray.exe. No harm in that – apart from the fact that any other switch than /launch is not passed on and will result in – nothing!

Why is this important? The App-V team introduced the most wonderful switch /EXE which is explained a lot better by Aaron Parker in his App-V FAQ. (really – he explains it a lot better than I ever could).

How do you work around it?

Command-line that doesn’t work;
C:\Windows\CCM\VAppLauncher.exe /EXE cmd.exe /launch “Microsoft Expression Encoder 4 4.0.4276.0

Command-line that will work with any App-V Client configuration;
“C:\Program Files\Microsoft Application Virtualization Client\sfttray.exe” /EXE cmd.exe /launch “Microsoft Expression Encoder 4 4.0.4276.0

In ConfigMgr 2012 – any produced file type association and shortcut will using vapplauncher.exe as the starting point. To get the latter possibility to troubleshoot within the virtual environment – create a shortcut for SFTTRAY.EXE located in the installation folder of the App-V Client and append the /EXE and /launch switches with your application name and version as input (written in italics above).

Adobe Photoshop CS 6 and App-V

Adobe still has a problem with beeing virtualized using App-V and when certain versions of the Visual C++ Redistributable components aren’t available on both the sequencer and all possible clients that will run the software. Quite a few instances have been reported of software that has had similiar problems – but newer versions of Adobe consistently seem to run into the problem. There is a thread on appvirtguru.com named Adobe Photoshop CS6 recipe? that explains the errors when you attempt to sequence it.

The errors presented were;

Activation context generation failed for "Q:\PshopCS6.001\VFS\CSIDL_PROGRAM_FILES_COMMON\Adobe\OOBE\PDApp\core\adbeape.dll".Error in manifest or policy file "Q:\PshopCS6.001\VFS\CSIDL_PROGRAM_FILES_COMMON\
 Adobe\OOBE\PDApp\core\Microsoft.VC90.CRT\Microsoft.VC90.CRT.MANIFEST" on line 3. Component identity found in manifest does not match the identity of the component requested. Reference is Microsoft.VC90.CRT,processorArchitecture="x86",type="win32",version="9.0.21022.8". Definition is Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",
 type="win32",version="9.0.30729.4148". Please use sxstrace.exe for detailed diagnosis.

Activation context generation failed for "Q:\PshopCS6.001\VFS\CSIDL_PROGRAM_FILES_COMMON\Adobe\OOBE\PDApp\core\adbeape.dll". Dependent Assembly Microsoft.VC90.CRT,processorArchitecture="x86",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.

Reading the above information – you can see that a very specific component is missing – often relating to Microsoft VC90 CRT 9.0.21022.8 and Microsoft VC90 CRT 9.0.30729.4148. Those versions seems to be available in Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package ATL Security Update – which you can download and pre-sequencing install on the sequencer and then also deploy to all clients who will be running the virtualized package.

Other notes;

Sequencing Adobe CS6 for App-V – Part 1, the prep

Sequencing Adobe CS6 for App-V – Part 2, the sequencing

Sequencing Adobe CS6 for App-V – Part 3, the testing/how/why

“Gotcha” when sequencing Adobe CS6 (Malformed XML when importing)

CAPICOM and Windows Server 2008 R2

If a software is dependent on the CAPICOM module for authentication and you get this error when you attempt to login to the system on a newer platform (such as Windows Vista, Windows 7 or their newer brothers in server-editions) – it can be resolved using quite straightforward methods.

image
Encryption failed. The requested operation is not supported in this platform. (0x80880900)

You need the following things;
Platform SDK Redistributable: CAPICOM
Security Update for CAPICOM (KB931906)

Download and install them in the above listed order.
Once the installation is completed – the actual files we need are placed in this directory;

C:\Program Files\Microsoft CAPICOM 2.1.0.2\Lib\X86

Copy the file to c:\windows\system32 (on a 32-bit system that is, for a 64-bit system we need to place it into c:\windows\syswow64)

Run the following command to register the newly copied module;
regsvr32 c:\windows\system32\capicom.dll

Once this is completed – the error should be resolved in the next login attempt

Failed to open graphics server

Did you get the error message Failed to open graphics server when sequencing a program? Did you implement the solution posted in the App-V Technet forums – and still get the error message?

The below process monitor capture will tell you why- it actually looks in both the current working directory and where it is located. Make a copy to the current working directory – and it will probably be ok!

gsw

Setup a VM for packaging

1. Install Windows 7 that corresponds to your environment (Pro N x86 is my edition)

2. Disable User Account Control

3. Disable System Protection

4. Run Quest vWorkspace Desktop Optimizer

5. Install .NET Framework 4.0

6. Install prerequisites;

Visual C++ 2005
VC++ 2005 SP1
VC++ 2005 SP1 ATL security update
VC++ 2005 SP1 MFC security update
VC++ 2008
VC++ 2008 SP1
VC++ 2008 SP1 with ATL security update
VC++ 2008 SP1 MFC security update
VC++ 2010 SP1
VC++ 2012 Update 3
VC++ 2013
Visual J# 2.0
VS 2010 F# 2.0 SP1
.NET Framework 4.5.1

7. Set keyboard layout

8. Ensure VMware Tools are updated

9. Disable all power-settings

10. Run MSCONFIG and disable GUI of boot

11. Remove any excess hardware (floppy-drive, usb-devices)

12. Create shortcuts to any mapped drives / source-folders on the desktop

13. Show all icons in the system tray

14. Run Windows Update (might need to re-enable the service)

15. Activiate Windows

App-V and .appv

So, you created a package and wanted to discover what was in it. One way to peak inside of a package – is to simply rename the binary-file from .appv to .zip.

Is it supported? Probably not

What happens if you do it?

You can see the contents;

image

If you copy the registry.dat file outside and open regedit and choose the following menu;

image

Select the file and name the hive (something that makes sense) – you will then see the following;

image

The hive in question is HKEY_LOCAL_MACHINE and APPV (which is what was chosen as name).

What does this mean? Well… You can see the files and the registry parts of a package. But is this supported? Lets divide it into a few different parts;

1. Make a copy of the package – rename it to .zip and mount the .DAT-file into the registry. Seems OK

2. Rename the original file to .zip and then rename it back to .appv.
Seems unlikely to be ok

3. Rename the original file to .zip, make changes to the registry and / or file-structure and then rename it back to .appv
Seems likely to be your-way-out-of-support-scenario

4. Does it seem like a lot more work then Application Virtualization Explorer?
YES!

App-V 5 and OS integration

One of the new features that App-V 5 brings to the table is the possibility to more seamlessly integrate to the operating system. But, what does that mean in practice?

Well, if you sequence Mozilla Thunderbird – the following things show up…

Protocol Handlers;

image

Default Program Handlers;

image

This means that if you click a link like this;

image

A new mail will be presented;

image

(guessing that the empty subject / to-field relates to beta-code Smile )

If you sequence InstEd – more things will be available on the right-click of MSI-files that previously wasn’t there see the Instead It! menu-option)

image

Of course there are many more features to come – but Application Virtualization just took a major step forward in bringing a native application experience.

Config Mgr 2012 and App-V

Previously when using App-V and leveraging the infrastructure of SCCM 2007 and the integration of the App-V you were “limited” to using anything from Configuration Manager. In itself – this wasn’t all that bad, but any type of migration scenario were very much dreaded and the enabling or disabling of the integration was a big on-off switch – that dropped anything previously distributed to App-V Client and took over the control of the client. Configuration Manager 2012 has come a long ways and especially when migrating between different scenarios – it isn’t as controlling in some scenarios.

First – a few notes; There isn’t any configuration on the Configuration Manager 2012 infrastructure or client that enables or disables any functionality. By default – its capable of integration with App-V and will do so without any particular tasks required to be performed by the administrator. Reviewing a previously installed App-V Client that has one single application distributed gives us the following views;

(registry configuration to start an application)

image

(one application distributed using stand-alone method)

image

Even though this wasn’t part of the experiments conducted today – any Publishing Servers should be removed once the client controlled by Configuration Manager 2012. Not only once – but it should continuously be removed in the future.

After installing Configuration Manager client, adding applications and creating new deployment (that didn’t require the install – so we could control the time of installation) for our device – the above registry keys didn’t change. Once we initiated the deployment and installed the App-V package – the registry keys switched to the below;image

Interesting part is that the old application is still there and will still start (as opposed to using the integration with Configuration Manager 2007 – where it would not start). What was rather surprising though – is that even though all three applications are started, the one not distributed via Configuration Manager 2012 will never say that it is In Use.

image