Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Backup
Links ......................................................................................................................................................... 2
SQL Server Tools in 2008 R2 .................................................................................................................... 2
Creating a Database ................................................................................................................................ 2
Using T-SQL Database Creation ............................................................................................................... 3
T-SQL for Creating Database ................................................................................................................... 3
Database Properties ................................................................................................................................ 5
Creating A Database Owner Account ...................................................................................................... 6
Security Folders ....................................................................................................................................... 9
Backup of the Database......................................................................................................................... 11
Manual Backup ...................................................................................................................................... 13
Differential Backup ................................................................................................................................ 18
Automating Backup ............................................................................................................................... 19
Links
Below are the most often used Tools in SQL Server 2008 R2
Creating a Database
This is a fresh Database creation and the screenshots below show what will be saved in
these folders once a Database is created.
The Log file will be present here once the database is created
If you prefer to create Database using GUI then right click on "Databases" select "New
Database"
Below is using Command line which is also a good thing to practise. Below is the screenshot
and next to it is the T-SQL to create database. Select all the lines and press "Execute" Button
Click on "New Query" Button to write T-SQL and change the Paths as suitable to you
USE [master]
GO
CREATE DATABASE [EuropeDB]
ON
PRIMARY
Click on "Refresh" Button to see the Database, which is highlighted below if you do not see
the Database
Database Properties
None would save everything on one File and consider as that as Storage for data. So, Files
and Filegroups is the way to go and store the data
The Database Role "db_owner" makes a User Account a demy God of the database
In this procedure AD (Active Directory) Account is not used
Right click on Users to create an Account . The below screens shows it
Click on User Mapping to assign Database Roles to this User Account. In this Test the User
has other roles too that are "data_reader" and "data_writer" along with "db_owner"
Database Role
Login to the System using this account and connect the Database
Finally create a test Schema and Table to see whether User has the rights to create Data and
Read Data from this Database
Security Folders
Below is the screenshot that shows the existence of a Security Folder for an Instance, System
Databases and User Database
The main purpose of it is quite straight. If an account exists in these Security Folder then
there is access to a User
Using GUI, right click on this newly created Database and on 'Properties'. The General Tab
shows when was the last time a Backup was made for a Database
Let's create an account that is used for Backup of all the Databases of this Instance
Creating an account to shown in "Creating A Database Owner Account". Just create an
account and then double click the account to assign relevant "Roles" to this account using
SSMS Tool (SQL Server Management Studio)
In Server roles assign "sysadmin" and then click on "User Mapping" to assign the databases
that this User will be doing Backups
Assign "Database Backup Operator" Database Role. The User needs this Database Role for
every Database that you select
Manual Backup
Login to the System using account. Right click on the Database and click on 'Properties' to see
when was the last time a Backup was made
Doing a Backup of the Transaction Log is part of the Backup
User Database Backup that is "EuropeDB" in this case and the Recovery Model is "Full"
Verify of the Backup. Navigate to this folder to verify the existence of Backup
Differential Backup
What we did in latter step was a Full Backup. See the "Recovery Model" in the above screens
In the below screens it is about doing the Differential Backup
Automating Backup
Each time it is not possible to do a Manual Backup watching the Clock so the backups needs
to be automated
Below is the basic overview of automating the backup
Showing the initial screens how a Backup can be automated