简体   繁体   中英

SQL Server - backup of PRIMARY filegroup + the Log file

I have tried backing up my primary filegroup (have 3 other filegroups i dont need to restore) and the log file using:

 BACKUP DATABASE [dblive]  
 FILEGROUP = N'PRIMARY',   
 TO  DISK = N'C:\SQL_Backups\test2_primary.bak' 
 WITH NOFORMAT, NOINIT,  
 NAME = N'dblive-Full Filegroup Backup', 
 SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO
BACKUP LOG [dblive] TO  DISK = N'C:\SQL_Backups\test2_log.bak' 
WITH NOFORMAT, NOINIT,  
NAME = N'dblive-Transaction Log Database Backup', 
SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO

i zip up the files from the customer site (db in full recovery mode) and restore inhouse. when i run the restore:

   RESTORE DATABASE [CustomerDB] 
  FROM  DISK = N'C:\backups\CustomerDB\test2_primary.bak'
  WITH  recovery,  
  MOVE N'AwardsBA_DB' TO N'C:\Databases\CustomerDB\CustomerDB.mdf',  
  MOVE N'AwardsBA_DB_log' TO N'C:\Databases\CustomerDB\CustomerDB.ldf',    
 NOUNLOAD, REPLACE,  STATS = 10

 RESTORE LOG CustomerDB FROM DISK = 'C:\backups\CustomerDB\test2_log.bak'  
   WITH RECOVERY; 

i get this error message

"This log cannot be restored because a gap in the log chain was created"

Any ideas on how i can backup this Primary filegroup and Log and restore them inhouse?

You won't be able to restore that log so you have to create a new one.

RESTORE DATABASE [CustomerDB] 
  FROM  DISK = N'C:\backups\CustomerDB\test2_primary.bak'
  WITH  recovery,  
  MOVE N'AwardsBA_DB' TO N'C:\Databases\CustomerDB\CustomerDB.mdf',  
  MOVE N'AwardsBA_DB_log' TO N'C:\Databases\CustomerDB\CustomerDB.ldf',    
 NOUNLOAD, REPLACE,  STATS = 10

ALTER DATABASE [CustomerDB] SET EMERGENCY, SINGLE_USER

ALTER DATABASE [CustomerDB] REBUILD LOG ON (NAME= AwardsBA_DB_log, FILENAME='C:\Databases\CustomerDB\CustomerDB_1.ldf')

ALTER DATABASE CNBILL SET ONLINE, MULTI_USER

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM