Compress SQL Server Backup in Right Way

Databases have the nasty habit of growing to mammoth sizes with continued usage over years. And it is common knowledge that databases that grow too large become prone to problems such as corruption, mismanagement etc. It thus becomes important to keep tabs on their growing sizes before they reach the point of no return. That’s why organizations engage in frequent backing up and shrinking of entire databases (which is not a very safe option). However, just as the databases can

» Read more

SQL Server 2012 – Get Backup History of the database

The msdb database is system database used by SQL Server Agent for scheduling alerts and jobs. msdb.dbo.backupset – Contain the information concerning the most-granular details of the backup process msdb.dbo.backupmediafamily – Contains the metadata for the physical backup files as they relate to backup sets Using the above mentioned tables, we will find the backup history of database Script: SELECT s.database_name, m.physical_device_name, CAST(CAST(s.backup_size / 1000000 AS INT) AS VARCHAR(14)) + ' ' + 'MB' AS Backup_Size, CAST(DATEDIFF(second, s.backup_start_date,s.backup_finish_date) AS VARCHAR(4))

» Read more

Schedule Automatic Backup in SQL Server 2012 – Part2

In the previous post, we have scheduled automatic backup in SQL Server 2012 – Part1. As we have scheduled daily backup of database and backup file will be generated every day. It is a good practice that to delete backup files after a certain period of time as per requirement. Now we will add the Maintenance Clean Up Task along with the Back Up Database Task. Configure Clean Up Task From the Maintenance Plan Tasks tool box pane in the left

» Read more

Schedule Automatic Backup in SQL Server 2012 – Part1

You know it is very important to back up your SQL server database backup on the regular basis. So in this post, we will see how to schedule automatic backup in SQL server 2012. We will go step by step to schedule so that we all can understand each and every step clearly. Before scheduling automatic backup we have make sure the following two points: User should have the SYSADMIN privileges to schedule automatic backup. SQL Server Agent service should

» Read more

SQL Server 2008 – Database Backup Compression

Backup compression was introduced in SQL Server 2008 Enterprise. At installation, backup compression default is set to 0, which makes backup compression off by default. To change the default to COMPRESSION, set backup compression default to 1. To revert the default to NO_COMPRESSION, set backup compression default back to 0. Backup Compress at Server Level (Thru Script) USE master; GO EXEC sp_configure 'show advanced option', '1'; RECONFIGURE GO EXEC sp_configure 'backup compression default', '1'; RECONFIGURE WITH OVERRIDE; GO EXEC sp_configure

» Read more

SQL Server 2008R2 – Database Restore – failed 38 (reached the end of the file)

While restoring the SQL database error occurred… Through UI following error occurred Through Script following error occurred Script: RESTORE DATABASE mydb FROM DISK = 'D:\ DB Backup\mydb.bak' WITH MOVE 'mydb_Data' TO 'E:\Database\mydb.mdf', MOVE 'mydb_Log' TO 'E:\Database\mydb.ldf', REPLACE GO Msg 3203, Level 16, State 1, Line 1 Read on “D:\ DB Backup\mydb.bak” failed: 38(Reached the end of the file.) Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. I have taken the other backup file then it

» Read more

SQL Server – Error 3154: The backup set holds a backup of a database other than the existing database

Sometime we faced the following error message while restoring the database Error 3154: The backup set holds a backup of a database other than the existing database. Solution: Use WITH REPLACE while using the restore script as Script 1 RESTORE DATABASE YourDB FROM DISK = 'C:\YourDB.bak' WITH REPLACE  Script 2 — Get the Logical file name of the database from backup. RESTORE FILELISTONLY FROM DISK = 'C:\YourDB.bak' GO RESTORE DATABASE YourDB FROM DISK = 'C\:YourDB.bak' WITH MOVE 'YourDB_Data' TO 'C:\Database\YourDB.mdf',

» Read more

Restore SQL 2008 full database backup to SQL Server 2005

My friend wants to restore the SQL 2008 full backup to SQL Server 2005. He faced an issue while restore the SQL 2008 full backup to SQL Server 2005. He has a question from me as: Can we restore the SQL 2008 full database backup to SQL Server 2005? Answer: No, we can’t restore a backup from a higher version of SQL Server on a lower version of SQL Server. Alternative: If you are not using any features specific to

» Read more

SQL Server – Mirror Backup of databases

It is very common practice to create an exact copy of the database backup and store it to different places so that in case any emergency or misfortune, DBA should have the alternative location to find the backup of databases.  Once a full backup is accomplished DBAs generally copy the database to another location in their network using utility tools like R-sync or native DOS commands like xcopy etc. Mirroring a media set increases backup reliability by reducing the impact

» Read more

SQL Server – Validation of Backup

Database backup are insurance policy for a database, we need to ensure that backups created are valid and useful. To validate the backup, we can use following command Restore verifyonly from <backup device> When a backups is validated, SQL Server performs the following steps Calculated a checksum for the backup and compare to checksum stored in the backup files Verify that the header of backup is correctly written and valid Transits the page chain to ensure that all pages are

» Read more

SQL Server – Backup Type for Each Recovery Model

Before looking about Backup type for each Model, sharing with brief information about Recovery and Recovery Model Recovery Recovery options determine the behavior of transaction log and how damaged pages are handled. Recovery Model Every database within a SQL server a SQL server instance has a property setting called recovery model. The recovery model determines the types of backups you can perform against a database. The recovery models available in SQL server 2008 are: Full Bulk-Logged Simple

» Read more

SQL Server – Backup all the sql server databases

Sharing with you script to backup all the SQL server databases Script: DECLARE @name VARCHAR(50) — database name DECLARE @path VARCHAR(256) — path for backup files DECLARE @fileName NVARCHAR(256) — filename for backup DECLARE @fileDate VARCHAR(20) — used for file name SET @path = ‘D:Backup’ SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),113) SELECT name,flag=0 INTO #temp FROM master.dbo.sysdatabases WHERE name NOT IN (‘master’,’model’,’msdb’,’tempdb’) –according to requirement we can filter databases in where clause SET ROWCOUNT 1 WHILE (exists(SELECT * FROM #temp WHERE flag=0))

» Read more
1 2