• No results found

Using TDP for SQL CLI

Appendix B. TDP for SQL CLI

B.1 Using TDP for SQL CLI

The Command Line Interface is where you will type your scheduled commands. To ease the task of writing scheduled jobs (cmd files), we recommend becoming familiar with the CLI.

The TDP for SQL Command Line Interface is started by executing the shortcut SQL Client CMD Line, as shown in Figure 68. Basically, it is a command line started in the directory where TDP for SQL is installed.

For example, all commands start with tdpsqlc followed by the command backup, then the positional parameter dbName, and the type for the command full, followed by optional parameters. In the following samples, some different types of backup and restores are listed. For a full list of commands, type tdpsqlc and press Enter, or use the TDP for SQL online documentation.

Full, log, and differential backup

To make a full backup of all databases on the SQL server (default instance) C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc backup * full

To specify a specific database replace * with dbname (case sensitive).

To use a different option file specify /tsmoptfile=Otherdsm.opt, if for example other node name include\exclude statements is wanted.

To make log or differential backup replace full with log or diff Backing up the log file from database InvoiceReg

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc backup InvoiceReg log

Group, file, and set backups

When doing group or file backup, you should specify which groups or files to backup. Also the use of * (wildcard) is possible to backup all (files or groups).

To back up the database file Stock_VLDB_Data from database Stock_VLDB:

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc backup Stock_VLDB file=Stock_VLDB_Data

To back up the PRIMARY group from database Stock_VLDB:

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc backup Stock_VLDB group=primary

When doing a Set backup, you must specify /files=file1,file2... or /groups=group1,group2...Here you can also use * (wildcard).

In this example, a set backup of the group secondary is backed up from the database Stock_VLDB:

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc backup Stock_VLDB set

Restore from the command line interface

It is seldom necessary to schedule restore jobs, unless log shipping or automated restore tests are done, and you will probably find it easier to use the TDP for SQL GUI. Therefore, the following restore example shows how to do partial restores while relocating the files (this cannot be done from the TDP for SQL GUI).

Relocating files while doing partial restore

Below, the filegroup PRIMARY from the full database backup of the database DB_Name on Rainier is restored on another server, into the new database DB_Part (which is created in the restore process), relocating the files to a location, and different physical file names than contained in the backup object.

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc rest DB_Name full /fromsqlserver=rainier /partial /groups=PRIMARY /into=DB_Part /relocate=DB_Name_Data,DB_Name /to=c:\temp\File1.mdf,c:\temp\Log.ldf

The corresponding restore while restoring the file group TERTIARY, is shown below, notice that the PRIMARY filegroup must always be restored when doing partial restores.

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc rest DB_Name full /fromsqlserver=rainier /partial /groups=TERTIARY /into=DB_Part3 When doing group, file, and set backup, you must also back up the log to be able to restore the backup object. See also “Need to back up tail of log before restore” on page 125

Note

To use the /relocate option with TDP for SQL CLI, first apply:

Fix patch 2.2.0.01, APAR: IC30018.

Note

Queries from the CLI

Queries from the CLI can be very helpful to get a good overview of your backup objects. The following examples show how to do queries.

When performing queries from the CLI, you can query the TSM server, SQL server or TDP.

When querying TDP, the TDP for SQL settings are listed shown below

When querying the SQL server information about the databases are listed.

You can specify to query a specific database or use * (wildcard), to get information about all databases on the server. A subset is shown:

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc query tdp Tivoli Storage Manager

Tivoli Data Protection for Microsoft SQL Server Version 2, Release 2, Level 0.01

(C) Copyright IBM Corporation 1997, 2001. All rights reserved.

TDP for Microsoft SQL Server configuration settings

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc query SQL * Tivoli Storage Manager

Tivoli Data Protection for Microsoft SQL Server Version 2, Release 2, Level 0.01

(C) Copyright IBM Corporation 1997, 2001. All rights reserved.

SQL Server Information SQL Database Data Space Allocated... 11,993,088 SQL Database Data Space Used... 11,993,088 SQL Database Log Space Allocated... 786,432 SQL Database Log Space Used... 351,232 SQL Database Options... System database

Truncate log on checkpoint Torn page detection SQL Database Name... model

SQL Database Data Space Allocated... 655,360 SQL Database Data Space Used... 655,360 SQL Database Log Space Allocated... 524,288 SQL Database Log Space Used... 263,168 SQL Database Options... System database

Torn page detection SQL Database Name... msdb

SQL Database Data Space Allocated... 11,796,480 SQL Database Data Space Used... 11,796,480 SQL Database Log Space Allocated... 2,359,296 SQL Database Log Space Used... 1,038,336 SQL Database Options... System database

Truncate log on checkpoint Torn page detection SQL Database Name... NewDB

SQL Database Data Space Allocated... 46,137,344 SQL Database Data Space Used... 2,097,152 SQL Database Log Space Allocated... 12,582,912 SQL Database Log Space Used... 1,224,704

SQL Database Options... Torn page detection SQL Database Name... Northwind

SQL Database Data Space Allocated... 2,752,512

When querying the TSM server, you can get information about which node name is used and how the node name is defined on the TSM Server, as shown:

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc query tsm Tivoli Storage Manager

Tivoli Data Protection for Microsoft SQL Server Version 2, Release 2, Level 0.01

(C) Copyright IBM Corporation 1997, 2001. All rights reserved.

Tivoli Storage Manager Server Connection Information ---Nodename... RAINIER_SQL2 NetWork Host Name of Server... 9.1.150.57

TSM API Version... Version 4, Release 1, Level 2 TSM Server Name... BRAZIL

TSM Server Type... AIX-RS/6000

TSM Server Version... Version 4, Release 1, Level 2.0 Compression Mode... ON

Domain Name... TDPSQL2_DOMAIN Active Policy Set... STANDARD Default Management Class... API_DISK_30DAYS

To get information about available backup objects, specify the type

parameter and /fromsqlserver=servername if it is not the default SQL server, as follows:

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc query tsm * type /fromsqlserver=rainier Tivoli Storage Manager

Tivoli Data Protection for Microsoft SQL Server Version 2, Release 2, Level 0.01

(C) Copyright IBM Corporation 1997, 2001. All rights reserved.

Backup Object Information

---SQL Database Name... AddressCat SQL Server Name... RAINIER Number of Full Active Backup Objects.. 1 SQL Database Name... InvoiceReg SQL Server Name... RAINIER Number of Full Active Backup Objects.. 1 SQL Database Name... master SQL Server Name... RAINIER Number of Full Active Backup Objects.. 1 SQL Database Name... model SQL Server Name... RAINIER Number of Full Active Backup Objects.. 1

For detailed options about each object you must specify the object in the query. Below the Log backups for Stock_VLDB are queried:

For further information on using the CLI, consult TDP for SQL Books Online.

C:\Program Files\Tivoli\TSM\TDPSql>tdpsqlc query tsm Stock_VLDB log=* /fromsqlserver=ra er

Tivoli Storage Manager

Tivoli Data Protection for Microsoft SQL Server Version 2, Release 2, Level 0.01

(C) Copyright IBM Corporation 1997, 2001. All rights reserved.

Backup Object Information

Backup Creation Date / Time... 04/05/2001 18:31:03 Backup Size... 82,432

Database Object Name... 20010405183103\00000988 Number of stripes in backup object... 1

SQL Server Name... RAINIER SQL Database Name... Stock_VLDB Backup Object Type... Log Backup Object State... Active

Backup Creation Date / Time... 04/05/2001 19:30:24 Backup Size... 82,432

Database Object Name... 20010405193024\0000078C Number of stripes in backup object... 1

SQL Server Name... RAINIER SQL Database Name... Stock_VLDB Backup Object Type... Log Backup Object State... Active

Backup Creation Date / Time... 04/05/2001 20:30:25 Backup Size... 15,872

Database Object Name... 20010405203025\000008D8 Number of stripes in backup object... 1

Related documents