HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to define the logical name in a backup ? ( Sql Server 2008 )

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
the2008sqlnamedefinehowserverlogicalbackup

Problem

I saw this question but it didn't help me.

Is there a simple way to do :

Backup database SomeDatabase 
   to disk ='c:\teste\SomeDatabase.bkp'


configuring the Logical Name?

We have some databases, restored of backups of another database (to follow same structure) and when I use RESTORE FILELISTONLY, it shows me a different name. So the Database TestDBA has the logical name BANK.

Solution

The logical file names returned by RESTORE HEADERONLY are those of the source database. You cannot change these logical names during the backup or restore. The backup file always contains the both the original logical and physical file names.

The original logical names may be specified with the MOVE option of RESTORE to relocate/rename the physical files during the restore process. After the restore, you can rename the logical names using ALTER DATABASE:

ALTER DATABASE Teste_Dan
MODIFY FILE(NAME='Teste_Ferdando_Index', NEWNAME='Teste_Dan_index');


Personally, I avoid including the database name in the logical name to avoid this issue, only including the database name in the physical name. Unfortunately, the database name is often included in the logical name by default.

Code Snippets

ALTER DATABASE Teste_Dan
MODIFY FILE(NAME='Teste_Ferdando_Index', NEWNAME='Teste_Dan_index');

Context

StackExchange Database Administrators Q#98138, answer score: 4

Revisions (0)

No revisions yet.