8.22 recovery back up

Recovery Model

  • how your dml operation to handle in log file
  • what back up operation you can use

1.1 what is

  • Database property that controls how transactions are logged and what restore operations are available
  • Typically a database uses Full or Simple recovery models
  • Can be switched at any time

1.2 Recovery Models

1.2.1 Simple

  • Little to no log backups

  • Reclaims space used by logs to keep requirements small

  • Unable to use Log Shipping, AlwaysOn, Database Mirroring, Point in Time Restores, and Media Recovery

  • doesn't hold any record in log file longer, doesn't have any log backup

  • performance faster, but lost log file
    但是他立刻去了mdf
    ???怎么做back up???

1.2.2 Full

  • No work is lost
  • Can recover to any point as it logs all transactions

1.2.3 Bulk-Logged

  • Permits high performance bulk copy operations for logs
  • Records bulk operation logs
difference

1.3 note

full;bulk-logged

  • 就算删除了数据,数据还是会在ldf,因为要做tail back up
    在没做back up之前,flag会是no,意味着不能重写,在做完log back up 之后,可以重写

区别:
bulk insert
full: 所有数据都插入
bulk-logged: 1000条1000条插入,只有10个enterence,当系统crush时候,back up的时候可以保存一部分(minial logging)

non bulk: row by row,log 存在ldf
bulk operations: 一块一块的插入,

2. back up

2.0 why we need it

  • prevent data loss
  • 访问量过大, high traffic
  • upgrade to different version
  • move database from one server to other server
  • hacker attacks
  • arctive(?) 旧的数据不用了,从sqlserver取出来

2.1 what is

  • Backups are used to make a compressed copy of the data in a database

  • Only backup data if it is online, any offline databases can’t be backed up

  • If a backup is started when a DB is being created, the backup will wait or time out

  • It is a mechanism that is provided by SQL Server to make copies of data at different levels. To handle situations like server/DB crashes or to maintain another copy of DB to support high traffic to DB situations. Most common reason is to prevent data loss in case of a crash.

2.2 type

2.2.1Full Backup

  • Copies all the data in a specific database with enough logs for recovering data

  • With this SQL Server takes back up of complete DB until the point of the back up. Usually this would take longer and resource intensive. For that reason it is not carried out very frequently. Depending on the size of DB or probability of crashing or minimum time required (defined by business) to recover the DB it is done once a month or twice a month.

  • complete db is backed up

  • eg: 200 gb delete need 3hr or 4hours, so we have a plan: once a month at 1st of this month 12:00am

2.2.2 Differential Backup

  • Records all the data that has been changed or modified since the last Full Backup

  • With this SQL Server takes back up of the data which is modified/added/deleted after last Full Back Up. Usually this will take few minutes to less than an hour depending on the frequency of changes on DB. If the frequency of changes on DB is high then more Differential back ups are recommended, it also depends on how frequently log back ups are taken.

  • eg: every day 120mb, but when 8am 40mb (full back up) differential back up(?)

2.2.3Transaction Log Backup

  • Records all the transaction logs that were not backed up in a previous Log Backup

  • This back up option backs up the data since last back up (any back up log/differential/full). This is most frequent back up type of all. Depending on the afford-ability (defined by business) of data loss, how fast the DB has to e brought online in case of crash, frequency of changes to DB it is decided that how many log back ups should happen in a given period. (This is not supported in Simple recovery model). Most common frequency is every 30 mins or 15 mins.

  • server doesn't fail

2.2.4 Tail-Backup

  • Records the latest log records that have not yet been backed up to prevent data loss

  • This option is used in case of a crash of DB in between 2 log back ups.

3. sql server job agent

3.1 what is

Tool in SQL that allows one to execute scheduled admin tasks or syntax
Great for performing backups late at night or doing long tasks that would take too much time to execute normally

3.2 opitions

  • Jobs – Specified actions to be taken in SQL
  • Schedules – Specified times when jobs run
  • Alerts – Automatic response to an event
  • Operators – Used to define contact for those responsible via Email

3.3 note

SQL Job Agent: It is a tool available in SQL Server to schedule a particular process (job). The job can be executing SQL code/SP, executing a SSIS package, running a batch file, processing a cube etc. A job can be created without schedule for ad-hoc execution. A job can contain multiple steps within it. Information about jobs and schedules are stored in MSDB. When a particular job executed successfully or failed you can see that info in the MSDB catalogs or history of the job.

4. disaster/recovery strategies

  • cold solution: backups
  • warm solutions: log shipping
  • hot solution: database mirroring
  • consider the following:
    size of db
    number of transactions that occur
    acceptable down time and data loss
    budget
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,294评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,780评论 3 391
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 161,001评论 0 351
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,593评论 1 289
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,687评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,679评论 1 294
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,667评论 3 415
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,426评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,872评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,180评论 2 331
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,346评论 1 345
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,019评论 5 340
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,658评论 3 323
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,268评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,495评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,275评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,207评论 2 352

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,320评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,460评论 0 23
  • (7.3)揣情者,必以其甚喜之时,往而极其欲也,其有欲也,不能隐其情;必以甚惧之时,往而极其恶也,其有恶也,不能隐...
    海纳百川vs王者之风阅读 255评论 0 0
  • 今天在网络上听吴熙琄老师讲的叙事治疗的概念之一:搭脚手架。觉得特别的新奇,在此跟大家分享一下。 叙事非常重视搭脚手...
    息县心协沐风f阅读 1,398评论 0 1
  • 夜书 夜深人静的时候 才会发现 自己原来那么孤独 有一点点痛 走吧 去远足 去原始的丛林里 去深邃的汪洋中 也许野...
    编剧夜书先生阅读 499评论 0 1