The tail of the transaction log usually refers to the contents of the database's transaction log that has not been backed up.  Basically, every time you perform a transaction log backup, you are backing up the tail of the transaction log.

Then why all the fuss over this?  Well, the complication starts when the database's data files are no longer available, perhaps due to a media failure.  When this occurs, the next logical step is to back up the current transaction log, and apply this backup to the standby database.  You can back up the transaction log even though the data files are no longer available, using the NO_TRUNCATE option e.g.

BACKUP LOG AdventureWorks TO DISK = 'G:\Backups\AdventureWorks_log_tail.bak' WITH NO_TRUNCATE

You can then use the resulting log backup to bring the standby database to the state the database was in before the failure.

This is another good reason to place your transaction log files on different disks from the data files.  If they were on the same disks, a disk failure would prevent you from taking a backup of the transaction log.

Another complication is when your database is using the bulk-logged recovery model, and the current transaction log contains minimally logged transactions.  In this situation, a transaction log backup needs to store the modified data pages (extents).  If the data files are not available, you cannot back up the transaction log, even with the NO_TRUNCATE option.

Lastly, in SQL Server 2005 and above, every time you try to restore a database which already exists, is using the full or bulk-logged recovery models, and the transaction log contains active transactions, an error similar to the following is displayed:

Server: Msg 3159, Level 16, State 1, Line 1
The tail of the log for the database "AdventureWorks" has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log. Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

This is just SQL Server's way of telling you that there are log records in the transaction log that have not been backed up. If the current transaction log can be discarded, you can use the REPLACE option to tell SQL Server to ignore the current transaction log e.g.

RESTORE DATABASE AdventureWorks FROM DISK = 'G:\Backups\AdventureWorks_full.bak' WITH REPLACE

Backing up the tail的更多相关文章

  1. 转载:Restore SQL Server database and overwrite existing database

    转载自:https://www.mssqltips.com/sqlservertutorial/121/restore-sql-server-database-and-overwrite-existi ...

  2. 数据备份与恢复 半持久化 全持久化 fork aof rdb Backing up Disaster recovery 备份 容灾

    Redis数据备份与恢复 - 流年晕开时光 - 博客园 https://www.cnblogs.com/deny/p/11531355.html Redis数据备份与恢复 Redis所有数据都是保存在 ...

  3. head/tail实现

         只实现了head/tail的基本功能,默认显示十行及-n参数.       一.使用带缓冲的系统调用.       write/read等系统调用是不带缓冲的,可以包装一层,使其带缓冲. t ...

  4. REDHAT一总复习1 输出重定向及head tail的用法

    1.使用bash命令,在server机上完成以下任务.(考点是:head  tail的使用) .显示/usr/bin/clean-binary-files文件的前12行,并将其输出到/home/stu ...

  5. tail命令详解

    搜索 纠正错误  添加实例 tail 在屏幕上显示指定文件的末尾若干行 补充说明 tail命令 用于输入文件中的尾部内容.tail命令默认在屏幕上显示指定文件的末尾10行.如果给定的文件不止一个,则在 ...

  6. Linux命令详解之—tail命令

    tail命令也是一个非常常用的文件查看类的命令,今天就为大家介绍下Linux tail命令的用法. 更多Linux命令详情请看:Linux命令速查手册 Linux tail命令主要用来从指定点开始将文 ...

  7. linux命令之tail

    tail用于输出文件末尾部分.一个比较有用的功能是tail + grep实现类似于安卓开发时调试使用的logcat,具体操作是: 一般我是用SecureCRT连接linux,然后使用SecureCRT ...

  8. PHP实现linux命令tail -f

    PHP实现linux命令tail -f 今天突然想到之前有人问过我的一个问题,如何通过PHP实现linux中的命令tail -f,这里就来分析实现下. 这个想一想也挺简单,通过一个循环检测文件,看文件 ...

  9. tail -f 和 -F 的用法

    tail -f 和 -F 的用法  Tai 2010-08-16 16:03:18 -f 是--follow[=HOW]的缩写, 可以一直读文件末尾的字符并打印出来."[=HOW]" ...

随机推荐

  1. 如何修改SQL Server 2008数据库服务器名称

    在做数据库发布订阅的时候我们经常要碰到要使用服务器名称来进行. 那么我们经常会碰到的问题是,现在开始大量的使用云服,我们只需要一台服务器搭建好环境,做一个备份镜像,还原到其他的服务器上就可以了,但是问 ...

  2. js将 HTML 页面生成 PDF 并下载

    最近碰到个需求,需要把当前页面生成 pdf,并下载.弄了几天,自己整理整理,记录下来,我觉得应该会有人需要 :) 先来科普两个插件: html2Canvas 简介 我们可以直接在浏览器端使用html2 ...

  3. OleDbCommand使用参数应该注意的地方

    最近写程序用到OleDbCommand的Parameter写数据库,遇到很多问题: 1.OLE DB .NET Framework 数据提供程序和 ODBC .NET Framework 数据提供程序 ...

  4. Gitlab项目用ssh克隆

    Gitlab项目用ssh克隆 1.  新建一个文件夹并用git bash here 打开 2.  在git bash here 输入命令行 ssh-keygen –t rsa –C“邮箱名” 3.  ...

  5. IOS-Core Data的使用

    二.Core Data的使用(一) CoreData 1.  常用类和方法   ( 注意需要导入   coredata  框架   ) 表结构:NSEntityDescription 表记录:NSMa ...

  6. python3连接MySQL数据库实例

    #python3连接MySQL实例 import pymysql """导入连接MySQL需要的包,没有安装pymysql需要先安装 使用命令行切换到python的安装路 ...

  7. hdu 3268 09 宁波 现场 I - Columbus’s bargain 读题 最短路 难度:1

    Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera ...

  8. MYeclipes项目导入导出

    导入: 右键,import,

  9. IE9(8)跨域(CORS)解决方案

    HTML5中 XMLHttpRequest Level 2 的推出.可以通过在返回的HTTP请求头中加入 Access-Control-Allow-Origin 的设置,让浏览器支持对不同域的AJAX ...

  10. 捕捉过滤器(CaptureFilters)和显示过滤器(DisplayFilters)--Wireshark

    Wireshark的基本使用——过滤器 前言 网络上关于Wireshark的教程已有不少,博主就简单介绍一下Wireshark分析数据包时最重要的技巧之一的过滤器..一次性嗅探到的数据包有很多,想要高 ...