利用Log還原資料庫到某一時間點
/*利用log還原到時間點*/
-- 第一部分_建立資料庫PrimaryDB01
use master;
go
create database PrimaryDB01
on primary
(
name =PrimaryDB01_data01,
filename='c:\PrimaryDB01_data01.mdf'
),
(
name =PrimaryDB01_data02,
filename='c:\SQL2008\PrimaryDB01_data02.ndf'
)
LOG ON
(
name = PrimaryDB01_log01,
filename ='c:\PrimaryDB01_log01.ldf'
),
(
name =PrimaryDB_log02,
filename ='c:\SQL2008\PrimaryDB01_log02.ldf'
)
Go
-- 第二部分
use PrimaryDB01;
go
create table tab01(id int) --建立表tab01,插入資料
go
insert into tab01 values(1);
insert into tab01 values(2);
insert into tab01 values(3);
create table tab02(name varchar(25));--建立表tab02,插入資料
insert into tab02 values('a');
insert into tab02 values('b');
insert into tab02 values('c');
--第三部分
use PrimaryDB01;
go
-- 資料庫PrimaryDB01進行full backup
backup database PrimaryDB01 to disk='c:\PrimaryDB01_data.bak' with format;
--檔案備份後 對資料庫資料進行災難模擬處理
--第四部分
***********************************************************
/*1 模擬丟失資料檔案,還原後資料庫資料的丟失情況*/
***********************************************************
use PrimaryDB01;
GO
create table tab03(id int);
insert into tab03 values(1);
--刪除了資料檔案PrimaryDB01_data02.ndf
--恢復資料檔案
--1 首先需要備份當前的日誌
backup log PrimaryDB01 to disk ='c:\PrimaryDB01_log.bak' with format,no_truncate;
***************************************************************************
By default, when you perform. a transaction log backup from the SQL Server Enterprise Manager Backup Database dialog box, the Remove inactive entries from transaction log checkbox under the Options tab is selected so the backup should be performed without the NO_TRUNCATE option. However, if you perform. the backup and you do not click the Options tab, the server issues the backup log statement with the NO_TRUNCATE option so the entries for completed transactions are not removed from the transaction log upon completion of the backup. If you click the Options tab before you perform. the backup, the server issues the backup log statement without the NO_TRUNCATE option as expected.
***************************************************************************
use master;
go
--2 利用fullbackup 恢復被破壞的檔案
restore database PrimaryDB01 from disk='c:\PrimaryDB01_data.bak' with norecovery;
--3 利用備份的日誌檔案還原到破壞點
restore database PrimaryDB01 from disk='c:\PrimaryDB01_log.bak' with recovery;
--------------查詢資料庫的資料丟失情況
select *from tab03;--------------結果顯示資料沒有丟失、正確利用了Log備份檔案
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24867586/viewspace-710854/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 將 SQL Server 資料庫還原到某個時點(完整恢復模式)SQLServer資料庫模式
- 從32位資料庫還原到64bit資料庫open的時候報錯資料庫
- 如何將Azure SQL 資料庫還原到本地資料庫例項中SQL資料庫
- DM7使用DMRMAN恢復資料庫到指定時間點/LSN資料庫
- Linux時間還原Linux
- Sqlserver資料庫使用 .bak 檔案還原資料庫SQLServer資料庫
- MySQL資料庫的備份還原方案——不同伺服器間MySql資料庫伺服器
- 織夢資料庫_織夢還原資料庫_織夢資料庫很卡資料庫
- sqlserver資料庫的備份還原SQLServer資料庫
- sqlserver資料庫備份,還原操作SQLServer資料庫
- Oracle匯出資料庫與還原Oracle資料庫
- 「MySQL」資料庫備份和還原MySql資料庫
- 「Oracle」Oracle 資料庫備份還原Oracle資料庫
- 【Mongodb】資料庫備份與還原MongoDB資料庫
- 通過事務日誌恢復SqlServer資料庫到一個特定的時間點SQLServer資料庫
- 還原sql server 2000資料庫的坑,不同版本資料庫SQLServer資料庫
- Mysql備份和還原資料庫-mysqldumpMySql資料庫
- 資料庫單表備份還原shell資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- DM7使用dmrestore執行指定時間點或LSN還原REST
- ORACLE資料庫基於時間點的不完全恢復Oracle資料庫
- Python - pandas 利用 某一列的值過濾資料Python
- 如何建立和還原SQL Server 2000資料庫?SQLServer資料庫
- 如何建立和還原SQL Server 2005資料庫?SQLServer資料庫
- 如何透過.dbf檔案還原資料庫資料庫
- SQLSERVER完整資料庫還原(完整恢復模式)SQLServer資料庫模式
- 達夢資料庫的備份與還原資料庫
- Oracle資料庫備份還原詳解XKUSOracle資料庫
- mysql資料庫-備份與還原實操MySql資料庫
- Oracle 11g用impdp還原資料庫Oracle資料庫
- java mysql 資料庫備份和還原操作JavaMySql資料庫
- DM7使用dmrestore工具還原資料庫REST資料庫
- 時間序列化資料庫選型?時序資料庫的選擇?資料庫
- Centos-Mysql複製備份還原資料庫CentOSMySql資料庫
- 資料庫的備份和還原不成功資料庫
- sqlserver資料庫還原儲存過程指令碼SQLServer資料庫儲存過程指令碼
- 7.5 使用binary log 做基於時間點的恢復
- 利用延時備庫找回被誤刪的資料
- [BUG反饋]使用mysqli資料庫驅動時,還原資料庫備份時,出錯,提示沒有 free_result()函式未找到!MySql資料庫函式