SQL Server Backup and Restore Shawn Mcgehee

Total Page:16

File Type:pdf, Size:1020Kb

SQL Server Backup and Restore Shawn Mcgehee The Red Gate Guide SQL Server Backup and Restore Shawn McGehee ISBN: 978-1-906434-74-8 SQL Server Backup and Restore By Shawn McGehee First published by Simple Talk Publishing April 2012 Copyright April 2012 ISBN 978-1-906434-85-4 The right of Shawn McGehee to be identified as the author of this work has been asserted by him in accordance with the Copyright, Designs and Patents Act 1988. All rights reserved. No part of this publication may be reproduced, stored or introduced into a retrieval system, or transmitted, in any form, or by any means (electronic, mechanical, photocopying, recording or otherwise) without the prior written consent of the publisher. Any person who does any unauthorized act in relation to this publication may be liable to criminal prosecution and civil claims for damages. This book is sold subject to the condition that it shall not, by way of trade or otherwise, be lent, re-sold, hired out, or otherwise circulated without the publisher's prior consent in any form other than that in which it is published and without a similar condition including this condition being imposed on the subsequent publisher. Technical Review by Eric Wisdahl Cover Image by Andy Martin Edited by Tony Davis Typeset & Designed by Peter Woodhouse & Gower Associates Table of Contents Introduction 12 ___________________________________________ Software Requirements and Code Examples 18 ________________________________ Chapter 1: Basics of Backup and Restore 19 ___________________ Components of a SQL Server Database 20 ___________________________________ Data files 20 ________________________________________________________ Filegroups 22 _________________________________________________________ Transaction log 24 ____________________________________________________ SQL Server Backup Categories and Types 28 __________________________________ SQL Server database backups 29 _________________________________________ SQL Server transaction log backups 32 ____________________________________ File backups 36 _______________________________________________________ Recovery Models 39 ______________________________________________________ Simple 41 ____________________________________________________________ Full 43 ______________________________________________________________ Bulk Logged 44 ______________________________________________________ Restoring Databases 46 ___________________________________________________ Restoring system databases 47 ___________________________________________ Restoring single pages from backup 48 ____________________________________ Summary 49 ___________________________________________________________ Chapter 2: Planning, Storage and Documentation 50 ___________ Backup Storage 50 ________________________________________________________ Local disk (DAS or SAN) 52 _____________________________________________ Network device 58 ____________________________________________________ Tape 59 _____________________________________________________________ Backup Tools 60 ________________________________________________________ Maintenance plan backups 61 ___________________________________________ Custom backup scripts 62 ______________________________________________ Third-party tools 63 ___________________________________________________ Backup and Restore Planning 64 ___________________________________________ Backup requirements 65 _______________________________________________ Restore requirements 68 ______________________________________________ An SLA template 69 __________________________________________________ Example restore requirements and backup schemes 71 _______________________ Backup scheduling 73 __________________________________________________ Backup Verification and Test Restores 75 _____________________________________ Back up WITH CHECKSUM 76 _________________________________________ Verifying restores 77 ___________________________________________________ DBCC CHECKDB 77 __________________________________________________ Documenting Critical Backup Information 78 _________________________________ Summary 83 ____________________________________________________________ Chapter 3: Full Database Backups 84 _______________________ What is a Full Database Backup? 84 _________________________________________ Why Take Full Backups? 85 ________________________________________________ Full Backups in the Backup and Restore SLA 86 _______________________________ Preparing for Full Backups 87 ______________________________________________ Choosing the recovery model 88 _________________________________________ Database creation 88 __________________________________________________ Creating and populating the tables 94 ____________________________________ Taking Full Backups 96 ___________________________________________________ Native SSMS GUI method 97 ____________________________________________ Native T-SQL method 106 ______________________________________________ Native Backup Compression 111 ____________________________________________ Verifying Backups 113 ____________________________________________________ Building a Reusable and Schedulable Backup Script 114 _________________________ Summary 115 ___________________________________________________________ Chapter 4: Restoring From Full Backup 116 ___________________ Full Restores in the Backup and Restore SLA 116 ______________________________ Possible Issues with Full Database Restores 117 ________________________________ Large data volumes 118 ________________________________________________ Restoring databases containing sensitive data 118 ___________________________ Too much permission 120 ______________________________________________ Performing Full Restores 122 _______________________________________________ Native SSMS GUI full backup restore 122 __________________________________ Native T-SQL full restore 129 ___________________________________________ Forcing Restore Failures for Fun 133 _________________________________________ Considerations When Restoring to a Different Location 136 _____________________ Restoring System Databases 137 ____________________________________________ Restoring the msdb database 138 ________________________________________ Restoring the master database 140 _______________________________________ Summary 143 ___________________________________________________________ Chapter 5: Log Backups 144 ________________________________ A Brief Peek Inside a Transaction Log 145 ____________________________________ Three uses for transaction log backups 148 ___________________________________ Performing database restores 149 ________________________________________ Large database migrations 150 ___________________________________________ Log shipping 151 _____________________________________________________ Log Backups in the Backup and Restore SLA 152 _______________________________ Preparing for Log Backups 153 _____________________________________________ Choosing the recovery model 154 ________________________________________ Creating the database 155 ______________________________________________ Creating and populating tables 157 _______________________________________ Taking a base full database backup 159 ____________________________________ Taking Log Backups 161 ___________________________________________________ The GUI way: native SSMS log backups 161 ________________________________ T-SQL log backups 166 _________________________________________________ Forcing Log Backup Failures for Fun 170 _____________________________________ Troubleshooting Log Issues 172 ____________________________________________ Failure to take log backups 173 __________________________________________ Other factors preventing log truncation 174 _______________________________ Excessive logging activity 175 ___________________________________________ Handling the 9002 Transaction Log Full error 176 __________________________ Log fragmentation 177 _________________________________________________ Summary 181 ___________________________________________________________ Chapter 6: Log Restores 182 ________________________________ Log Restores in the SLA 182 ________________________________________________ Possible Issues with Log Restores 183 ________________________________________ Missing or corrupt log backup 183 _______________________________________ Missing or corrupt full backup 184 _______________________________________ Minimally logged operations 184 _________________________________________ Performing Log Restores 187 _______________________________________________ GUI-based log restore 188 ______________________________________________ T-SQL point-in-time restores 194 ________________________________________ Possible difficulties with point-in-time restores 198 __________________________ Forcing Restore Failures for Fun 200 ________________________________________ Summary 204 __________________________________________________________ Chapter 7: Differential Backup and Restore 205 ______________ Differential Backups, Overview 206 ________________________________________ Advantages of differential backups 207 ____________________________________ Differential backup strategies 208 _______________________________________ Possible issues with differential backups 212 _______________________________ Differentials in the backup and restore SLA 215 _____________________________ Preparing for Differential Backups 216 _______________________________________ Recovery model 216 ___________________________________________________
Recommended publications
  • Protecting Miscrosoft® Hyper-V Environments
    Protecting Miscrosoft® Hyper-V Environments Who should read this paper Technical White Papers are designed to introduce Veritas partners and end users to key technologies and technical concepts that are associated with the Veritas™ Backup and Recovery product family. The information within a Technical White Paper will assist partners and end users as they design and implement data protection solutions based on Veritas Backup and Recovery products. Technical White Papers are authored and maintained by the Veritas Backup and Recovery Technical Services group. Veritas Backup Exec™ 15 Technical White Paper Protecting Hyper-V Environments Contents Introduction.......................................................................................3 Business Value....................................................................................3 Underlying Backup Principles.........................................................................7 Virtualized Application Protection .....................................................................10 Virtual Machine Recovery Options ....................................................................12 Improved Usability for Virtual Environments.............................................................15 Example Hyper-V Configurations .....................................................................16 Performance Recommendations .....................................................................17 Notes and Best Practices ...........................................................................18
    [Show full text]
  • Corpsystem Workpaper Manager
    CorpSystem Workpaper Manager Networking Best Practices Guide Version 6.5 Summer 2010 Copyright: 2010, CCH, a Wolters Kluwer business. All rights reserved. Material in this publication may not be reproduced or transmitted in any form or by any means, without prior written permission. Requests for that permission should be directed to: CCH INCORPORATED 21250 Hawthorne Blvd. Torrance, CA 90503 The contents of this publication are believed to be accurate. However, responsibility cannot be assumed for the information contained herein, and the consequences resulting from the use thereof. Material in this publication is subject to change without notice. This Networking Best Practices Guide and the computer software it describes are designed to provide accurate and authoritative information in regard to the subject matter covered. They are distributed with the understanding that the publisher is not engaged in rendering legal, accounting or other professional service. If legal advice or other expert assistance is required, the services of a competent professional person should be sought. “ProSystem fx” is a registered trademark of CCH, a Wolters Kluwer business. “Windows” is a registered trademark of Microsoft Corporation. All other brand, product, or company names are trademarks or registered trademarks of their respective owners. Printed in U.S.A Table of Contents Overview ........................................................................................................................................................................ 2
    [Show full text]
  • Copyrighted Material
    11_783269 bindex.qxp 11/10/06 11:15 AM Page 209 Index applications (defined), 205. See also programs Numerics arranging windows, 43–44 100% button (Internet Explorer 7), 99–100 assigning sounds to program events, 24 audio visualizations, 186 A Windows Media Player 11, 183, 185–186 accessibility options, 156 audio CDs. See CDs accessories, 205 Audio Description feature, 157 account types, 169 AutoComplete feature (Internet Explorer 7), 101 accounts (administrative), 169 automatic updates with Windows Update, 161–162, 167 accounts (e-mail), 124 AutoPlay, 13, 148, 151 accounts (user) Autosearching feature (Internet Explorer 7), 113 account types, 169 adding, 169 creating, 169 B deleting, 170 backgrounds for desktop, 24 managing, 168, 170 Backup and Restore Center, 140–143, 146 names, 169 Backup Files dialog box, 141 Parental Controls, 170 backups passwords, 169 CompletePC Backup utility, 140–142 pictures, 169–170 DVD discs, 142 switching, 74 File and Folder Backup utility, 140–142 User Account Control (UAC), 170 Send To shortcut menu command, 64–65 activity reporting, 165 stopping, 141 activity reports, 166 BitLocker drive encryption, 163–164 Add Printer Wizard, 149–151 blocking Add to Library dialog box, 187 computer use, 165 adding Web sites, 165 bookmarks to Favorites Center, 102 blog, 208 gadgets, 31–32 bookmarks (Internet Explorer 7) icons, 35 adding to Favorites Center, 102 languages, 155–156 deleting, 104 music, 187 importing, 101 printers, 149–151 moving, 103–105 user accounts, 169 organizing, 103–105 address bar, 15–16 renaming, 104 address book, 128–130 selecting, 103 Address toolbar, 41 browser (defined), 208. See also Internet Explorer 7 adjusting volume, 152 browsing offline.
    [Show full text]
  • Manage Backup and Restore Introduction Learning Outcomes
    CompTIA IT Fundamentals+ Manage Backup and Restore Introduction Lab Topology Exercise 1 - Create System Image Backup Exercise 2 - Schedule a Server Backup Review Introduction Backups System Image Server Backup Restore Welcome to the Manage Backup and Restore Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills. Learning Outcomes In this module, you will complete the following exercises: Exercise 1 - Create a System Image Backup Exercise 2 - Schedule a Server Backup After completing this lab, you will be able to: Add an additional virtual hard disk Initialize and create a new simple volume Create a system image backup Change the virtual machine start-up settings Perform system image restore Install Windows Server Backup Allow File and Printer Sharing feature Schedule a backup Exam Objectives The following exam objective is covered in this lab: 6.7 Explain business continuity concepts. Note: Our main focus is to cover the practical, hands-on aspects of the exam objectives. We recommend referring to course material or a search engine to research theoretical topics in more detail. Lab Duration It will take approximately 1 hour to complete this lab. Help and Support For more information on using Practice Labs, please see our Help and Support page. You can also raise a technical support ticket from this page. Click Next to view the Lab topology used in this module. Lab Topology During your session, you will have access to the following lab configuration. Depending on the exercises you may or may not use all of the devices, but they are shown here in the layout to get an overall understanding of the topology of the lab.
    [Show full text]
  • Microsoft Windows NT
    Microsoft Windows NT Securing Windows NT Installation October 23, 1997 Microsoft Corporation Contents Abstract Establishing Computer Security Levels of Security Off-the-Shelf vs. Custom Software Minimal Security Standard Security High-Level Security High-Level Software Security Considerations User Rights Protecting Files and Directories Protecting the Registry Secure EventLog Viewing Secure Print Driver Installation The Schedule Service (AT Command) Secure File Sharing FTP Service NetBios Access From Internet Hiding the Last User Name Restricting the Boot Process Allowing Only Logged-On Users to Shut Down the Computer Controlling Access to Removable Media Securing Base System Objects Enabling System Auditing Enhanced Protection for Security Accounts Manager Database Restricting Anonymous network access to Registry Restricting Anonymous network access to lookup account names and groups and network shares Enforcing strong user passwords Disabling LanManager Password Hash Support Wiping the System Page File during clean system shutdown Disable Caching of Logon Credentials during interactive logon. C2 Security Evaluation vs. Certification Setting up a C2-compliant System Abstract Microsoft® Windows NT® operating system provides a rich set of security features. However, the default out-of-the-box configuration is highly relaxed, especially on the Workstation product. This is because the operating system is sold as a shrink-wrapped product with an assumption that an average customer may not want to worry about a highly restrained but secure system on their desktop. This assumption has changed over the years as Windows NT gains popularity largely because of its security features. Microsoft is investigating a better secured default configuration for future releases. In the meantime, this white paper talks about various security issues with respect to configuring all Windows NT version 4.0 OS products for a highly secure computing environment.
    [Show full text]
  • Backup and Restore FAQ
    Backup and Restore FAQ Backup and Restore | Web, Data, and Email Protection | 15-Dec-2016 Applies to: TRITON AP-WEB and Web Filter & Security, v8.3.x TRITON AP-DATA, v8.3.x TRITON AP-EMAIL, v8.3.x ® Regularly back up configuration information for your Forcepoint™ TRITON solution so that you can revert to a previous configuration when needed. Data saved by the backup process can also be used to transfer configuration settings to a different machine or TRITON appliance. In most circumstances, when you use backup and restore to transfer configuration settings between servers, only same-platform transfers are supported. In other words, you can move from Windows to Windows or Linux to Linux, but not from Windows to Linux (or vice-versa). When backing up a TRITON management server, note that there are separate backup processes for TRITON infrastructure and other components on the machine. Synchronize the TRITON infrastructure backup with the backup procedures for other components. ● How do I back up and restore the TRITON infrastructure?, page 2 ● How do I back up and restore TRITON appliances?, page 6 ● How do I back up and restore web protection software?, page 8 ● How do I back up and restore Content Gateway?, page 16 ● How do I back up and restore TRITON AP-DATA?, page 18 ● How do I back up and restore TRITON AP-EMAIL off-appliance components?, page 21 ● How do I back up or restore web protection components and the TRITON Manager?, page 23 ● How do I back up or restore multiple TRITON AP-WEB appliances?, page 24 © 2016 Forcepoint LLC How do I back up and restore the TRITON infrastructure? Backup and Restore | Web, Data, and Email Protection | 15-Dec-2016 Applies to: TRITON AP-WEB and Web Filter & Security, v8.3.x TRITON AP-DATA, v8.3.x TRITON AP-EMAIL, v8.3.x The TRITON infrastructure backup process saves: ● Global configuration and infrastructure information, including administrator and appliance data, stored in the TRITON Settings Database.
    [Show full text]
  • Understanding Backup and Recovery Methods Lesson 8 Objectives
    Understanding Backup and Recovery Methods Lesson 8 Objectives Objective Domain Matrix Technology Skill Objective Domain Description Objective Domain Number Understanding Local, Online, and Understanding Local, Online, and 6.1.1 Automated Backup Methods Automated Backup Methods Understanding Backup Options Understanding Backup Options 6.1.2 Understanding System Restore Understanding System Restore 6.1.3 Understanding Recovery Boot Options Understanding Recovery Boot Options 6.1.4 Understanding Safe Mode Options Understanding Safe Mode Options 6.1.5 File Backup and Restore • A backup is a properly secured copy of files and folders—and sometimes settings—usually saved in a compressed format. • A backup is created so you can restore the files and settings in the event of data loss from a hard disk failure, accidental erasure or disk formatting, or natural events. File Backup and Restore • Windows Backup uses the Backup and Restore utility to back up and recover files. • You can automatic backups by scheduling them to run daily, weekly, or monthly. • You can store backups on CD/DVD, to another internal disk, to an external drive, or to a network drive. – Only Windows 7 Professional, Ultimate, and Enterprise editions enable file backups to a network. Backing Up Files Backing Up Files Backing Up Files Backing Up Files Backing Up Files Backing Up Files Backing Up Files Restoring Files Restoring Files Restoring Files Restoring Files Previous Versions • Each time a file is saved with changes, a previous version is created so you can roll back to an earlier version of a document if needed. • Right-click the file in Windows Explorer and choose Restore previous version.
    [Show full text]
  • EXPERTS System Windows 7 Backup and Restore
    System EXPERTS LEADERSHIP IN SECURITY & COMPLIANCE www.systemexperts.com 1 . 8 8 8 . 7 4 9 . 9 8 0 0 [email protected] Windows 7 Backup and Restore Tech Tip by Philip Cox © Copyright 2011 SystemExperts Corporation. All rights reserved. www.systemexperts.com System EXPERTS 1 . 8 8 8 . 7 4 9 . 9 8 0 0 LEADERSHIP IN SECURITY & COMPLIANCE [email protected] Windows 7 Backup and Restore Introduction What: You can use it to backup and restore system and data files on a Windows 7 system. You can use Everyone deals with the nightmare of lost data. We it to perform full system restores, as well as all know that having a reliable backup or restore individual files. The image-based full system backup mechanism is critical to any organization that relies option (i.e., system image backup) allows you to create on the data stored in their systems. One of the main an “image” of the entire system (effectively an headaches from a system administration point is image containing the entire contents of your system identifying a tool to provide reliable backup or at the time you created it). You can use this image restore functionality. This tech tip will look at one to perform a “bare metal” restore without first of those options. Specifically, the built-in backup or installing Windows. restore center of Windows 7. We will look at the latest functional changes to Windows’ Backup and When: The tool allows you to backup on a daily, Restore Center (WBRC), as well as discuss practical weekly, or monthly schedule.
    [Show full text]
  • How to Backup and Restore Microsoft DFS (Distributed File System) Using Zmanda Windows Client (ZWC)
    E-Mail: [email protected] Phone: 888-496-2632 408-732-3208 How to Backup and Restore Microsoft DFS (Distributed File System) using Zmanda Windows Client (ZWC) Introduction: In the modern computing infrastructure, one of the most common concept is “Virtualization. Similarly, in terms of virtual memory in operating systems, virtual disks, virtual networks and virtual machines in the IT infrastructure. Organizations those have virtual files distributed across different locations can organize them together into a logical tree with the help of Microsoft Distributed File System (DFS). Microsoft DFS is a mechanism which will allow you to create a logical view of your files, irrespective of where the files are physically stored on the network. Zmanda is a comprehensive data backup solution. Zmanda Windows Client (ZWC) can be used to backup and restore Distributed File System (DFS). Amanda Enterprise (AE) server connects DFS share via ZWC to perform backup and restore. Prerequisites: Create amandabackup user in active directory and provide full access to DFS share. A server to install Zmanda Windows Client (ZWC). You can install ZWC on any server or windows machine joined to your domain. Installation and Setup 1. Download, extract and run ZWC setup. 10901 W 120th Ave Suite 235, Broomfield, CO, United States. Tel: +1 720-452-6576 www.zmanda.com E-Mail: [email protected] Phone: 888-496-2632 408-732-3208 2. Enter password of amandabackup AD user which has full access to DFS share. 3. Enter Amanda Enterprise backup server FQDN or IP Address and complete the installation. 4. Go to ZMC (Zmanda management console) and create Object Windows NTFS/ReFS under Backup-what tab.
    [Show full text]
  • Computer Training Options Click Here
    Your Total Training Resource Microsoft® Windows 10® Learn how to perform management, wide varieties of operations, run myriads of built-in programs and maintenance tools of Windows 10. Perform managerial and maintenance commands and features. Learn about Windows essentials, tips and tricks, Managing files and folders on local, network and cloud storage areas like OneDrive. Learn how to customize the Windows environment to personalize the system to work best for you. Work with Cortana to control your computer with voice commands. The modules for Windows 10 are as follows: Module 1 – Learn All the Essential Features of Windows 10 To Schedule / Need Additional Information To schedule sessions, receive more information or for questions/clarifications contact us at: Email: Ken Keller at [email protected] or Dean Carroll at [email protected] or Phone: (630) 495-0505 or (800) 869-7497. To see a complete list of our current computer training options click here. 101 W. 22nd Street, Suite 100 630-495-0505 Lombard, IL 60148 630-495-1321 Fax www.c-kg.com Your Total Training Resource Module 1 – Learn All the Essential Features of Windows 10 • This comprehensive course covers everything you Edge browser, and work with Mail, Calendars, and need to know to install Windows, customize it to People (aka contacts). your liking, and start working with files and • Plus, learn about sharing via a home network, applications. multiuser configurations, security and privacy, and • See how to manage folders, use Cortana to search troubleshooting Windows. and navigate, browse the web with the new Microsoft Management and Maintenance: • Learn how to configure updates, monitor events and • Reviewing event logs.
    [Show full text]
  • CCH® Prosystem Fx® Engagement Installation Guide
    CCH® ProSystem fx® Engagement Installation Guide 2017 © 2017 CCH Incorporated and its affiliates and licensors. All rights reserved. Material in this publication may not be reproduced or transmitted, in any form or by any means, without prior written permission. Requests for that permission should be directed to: CCH Incorporated 20101 Hamilton Ave. Suite 200 Torrance, CA 90502 The contents of this publication are believed to be accurate. However, responsibility cannot be assumed for the information contained herein, and the consequences resulting from the use thereof. Material in this publication is subject to change without notice. This Installation Manual and the computer software it describes are designed to provide accurate and authoritative information in regard to the subject matter covered. They are distributed with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If legal advice or other expert assistance is required, the services of a competent professional should be sought. "CCH ProSystem fx Engagement" is a registered trademark of CCH INCORPORATED. “Windows” is a registered trademark of Microsoft Corporation. All other brand, product, or company names are trademarks or registered trademarks of their respective owners. Printed in U.S.A. Contents Installation 1 Engagement 2017 System Requirements 2 Administrator Module 2 Workpaper Management Module, including Knowledge Coach 5 Terminal Services Client Module 8 Terminal Services Database Module 9 Note Regarding
    [Show full text]
  • Back up SQL Server Database, Or Instance, Or Availability Group : Snapcenter Software
    Back up SQL Server database, or instance, or availability group SnapCenter Software NetApp September 16, 2021 This PDF was generated from https://docs.netapp.com/us-en/snapcenter/protect- scsql/reference_back_up_sql_server_database_or_instance_or_availability_group.html on September 16, 2021. Always check docs.netapp.com for the latest. Table of Contents Back up SQL Server database, or instance, or availability group . 1 Backup workflow . 1 Determine whether resources are available for backup. 2 Migrate resources to NetApp storage system . 3 Create backup policies for SQL Server databases . 5 Create resource groups and attach policies for SQL Server . 11 Requirements for backing up SQL resources . 14 Back up SQL resources . 14 Back up SQL Server resource groups . 17 Monitor backup operations. 17 Create a storage system connection and a credential using PowerShell cmdlets. 19 Back up resources using PowerShell cmdlets . 20 Cancel the SnapCenter Plug-in for Microsoft SQL Server backup operations. 21 View SQL Server backups and clones in the Topology page. 22 Remove backups using PowerShell cmdlets . 24 Clean up the secondary backup count using PowerShell cmdlets . 24 Back up SQL Server database, or instance, or availability group Backup workflow When you install the SnapCenter Plug-in for Microsoft SQL Server in your environment, you can use SnapCenter to back up the SQL Server resources. You can schedule multiple backups to run across servers simultaneously. Backup and restore operations cannot be performed simultaneously on the same resource. The following workflow shows the sequence in which you must perform the backup operations: The Backup Now, Restore, Manage Backups, and Clone options on the Resources page are disabled if you select a non-NetApp LUN, a database that is corrupted, or a database that is being restored.
    [Show full text]