Restoring MSSQL database to new location from command line with IBM TSM

Just a simple commands sequence with comments.

tdpsqlc.exe q tsm SOURCE_DB_NAME f /all

write down Database Object Name for needed full backup.

If you want to recover database backed up with options from dsm.opt file use following command:

tdpsqlc restore SOURCE_DB_NAME  full /into=DESTINATION_DB_NAME/RELocate=DATA_FILE_NAME,LOG_FILE_NAME /to=PATH_TO_DATA_FILE.mdf,PATH_TO_LOG_FILE.ldf /RECOVery=no /replace /object=DATABASEOBJECTNAME

If you want to recover database backed up with options different from dsm.opt, use following:

tdpsqlc restore SOURCE_DB_NAME full /into=DESTINATION_DB_NAME /RELocate=DATA_FILE_NAME,LOG_FILE_NAME /to=PATH_TO_DATA_FILE.mdf,PATH_TO_LOG_FILE.ldf /RECOVery=no /replace /object=DATABASEOBJECTNAME /tsmoptfile=other.opt

tdpsqlc.exe q tsm SOURCE_DB_NAME diff /all

Write down Database Object Name for needed diff backup

tdpsqlc restore SOURCE_DB_NAME diff /into=DESTINATION_DB_NAME /RELocate=DATA_FILE_NAME,LOG_FILE_NAME /to=PATH_TO_DATA_FILE.mdf,PATH_TO_LOG_FILE.ldf /RECOVery=no /replace /object=DATABASEOBJECTNAME

tdpsqlc.exe q tsm SOURCE_DB_NAME log=* /all

Write down Database Object Names for all needed log backups

tdpsqlc restore SOURCE_DB_NAME log=* /into=DESTINATION_DB_NAME /RELocate=DATA_FILE_NAME,LOG_FILE_NAME /to=PATH_TO_DATA_FILE.mdf,PATH_TO_LOG_FILE.ldf /RECOVery=no /object=DATABASEOBJECTNAME

…repeat for all needed logs

tdpsqlc restore SOURCE_DB_NAME log=* /into=DESTINATION_DB_NAME /RELocate=DATA_FILE_NAME,LOG_FILE_NAME /to=PATH_TO_DATA_FILE.mdf,PATH_TO_LOG_FILE.ldf /RECOVery=yes /object=DATABASEOBJECTNAME

Do not forget to add recovery=yes to last restored log.

Leave a Reply