backup and restore taking too long
raybouk
Posts: 12
I have 2 SQL Backup procedures that are taking too long to complete. The procedures backup a database to a NAS device and then restore the database from the NAS device to another SQL Server several hours later.
Below is the backup script from the main production server. It is scheduled for 7 PM daily. This one ran for 17 hours before I noticed it and stopped the job. It should run in a few hours.
=====
DECLARE @success int
EXEC @success=master..sqlbackup '-SQL "BACKUP DATABASE [MyDB]
TO DISK = ''\\MyNas\MyDB.sqb''
WITH NAME = ''MyDB Database'',
DESCRIPTION = ''Database: MyDB Instance: (local) Server: Production'',
INIT, COMPRESSION = 1" -E'
/* SQLBackup returns 0 for failure and 1 for success */
IF @success=0
BEGIN
RAISERROR('Backup Failed', 16,1)
END
====
Below is the restore script from the restore server. It is scheduled for 3 AM daily. This one ran for 53 hours before I noticed it and stopped the job. It too should run in a few hours.
====
DECLARE @success int
EXEC @success=master..sqlbackup '-SQL "RESTORE DATABASE [MyDB]
FROM DISK = ''\\MyNas\MyDB.sqb''
WITH RECOVERY,
REPLACE,
MOVE ''MyDB_data'' TO ''D:\MSSQL\Data\MyDB.mdf'',
MOVE ''MyDB_log'' TO ''d:\mssql\data\MyDB.ldf''" -E'
/* SQLBackup returns 0 for failure and 1 for success */
IF @success=0
BEGIN
RAISERROR('Restore Failed', 16,1)
END
====
This restore job is preceded by a step to set the database to single-user mode.
Any ideas on how to get these procedures to run correctly?
Thanks,
Ray
SS2K
Below is the backup script from the main production server. It is scheduled for 7 PM daily. This one ran for 17 hours before I noticed it and stopped the job. It should run in a few hours.
=====
DECLARE @success int
EXEC @success=master..sqlbackup '-SQL "BACKUP DATABASE [MyDB]
TO DISK = ''\\MyNas\MyDB.sqb''
WITH NAME = ''MyDB Database'',
DESCRIPTION = ''Database: MyDB Instance: (local) Server: Production'',
INIT, COMPRESSION = 1" -E'
/* SQLBackup returns 0 for failure and 1 for success */
IF @success=0
BEGIN
RAISERROR('Backup Failed', 16,1)
END
====
Below is the restore script from the restore server. It is scheduled for 3 AM daily. This one ran for 53 hours before I noticed it and stopped the job. It too should run in a few hours.
====
DECLARE @success int
EXEC @success=master..sqlbackup '-SQL "RESTORE DATABASE [MyDB]
FROM DISK = ''\\MyNas\MyDB.sqb''
WITH RECOVERY,
REPLACE,
MOVE ''MyDB_data'' TO ''D:\MSSQL\Data\MyDB.mdf'',
MOVE ''MyDB_log'' TO ''d:\mssql\data\MyDB.ldf''" -E'
/* SQLBackup returns 0 for failure and 1 for success */
IF @success=0
BEGIN
RAISERROR('Restore Failed', 16,1)
END
====
This restore job is preceded by a step to set the database to single-user mode.
Any ideas on how to get these procedures to run correctly?
Thanks,
Ray
SS2K
Comments
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Another SQL Server backed up to the NAS device (using SQL Backup) with a throughput of 24.466 MB/sec. I would backup locally and copy to the NAS device, but there isn't enough space.
Last night I had to stop the backup job because it was taking too long.
If you have a small database (about 100-200 MB), try making a backup to a local drive, and then to the NAS. What's the throughput in each case?
Then try copying a reasonably sized file to the NAS, from this SQL Server and another one, and compare the speed.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Just an FYI - these are the messages from my backup and restore jobs (the job step writes to files):
--- this is the backup - I would expect to see completion language but there isn't any:
Job 'Backup MyDB Database' : Step 1, 'backup MyDB' : Began Executing 2006-01-13 00:42:21
---- this is the restore - it either timed or or was stopped by me
Job 'restore MyDB nightly' : Step 3, 'restore MyDB' : Began Executing 2006-01-14 04:00:02
Msg 0, Sev 0: Operation canceled [SQLSTATE HY008]
Msg 0, Sev 0: Timeout expired [SQLSTATE HYT00]
Query cancelled.
To take the test a bit further, I used the SQL Backup application to backup locally and to the NAS. Both completed in a few seconds.
These are the local results:
1/16/2006 3:25:54 PM: Backup started ...
1/16/2006 3:26:13 PM: Backup completed.
1/16/2006 3:26:13 PM: Data size: 284.875 MB
1/16/2006 3:26:13 PM: Compressed size: 85.539 MB
1/16/2006 3:26:13 PM: Compression ratio: 70 %
SQL Server messages
Processed 36368 pages for database 'ImportDB', file 'ImportDB_Data' on file 1.
Processed 1 pages for database 'ImportDB', file 'ImportDB_Log' on file 1.
BACKUP DATABASE successfully processed 36369 pages in 16.645 seconds (17.898 MB/sec).
(1 row affected)
These are the NAS results:
1/16/2006 3:30:58 PM: Backup started ...
1/16/2006 3:31:26 PM: Backup completed.
1/16/2006 3:31:26 PM: Data size: 284.875 MB
1/16/2006 3:31:26 PM: Compressed size: 85.539 MB
1/16/2006 3:31:26 PM: Compression ratio: 70 %
SQL Server messages
Processed 36368 pages for database 'ImportDB', file 'ImportDB_Data' on file 1.
Processed 1 pages for database 'ImportDB', file 'ImportDB_Log' on file 1.
BACKUP DATABASE successfully processed 36369 pages in 24.610 seconds (12.105 MB/sec).
(1 row affected)
master..sqlbackup '-sql "BACKUP DATABASE northwind TO DISK = [<AUTO>]"'
It also takes forever to run and cancel the query.
1. when backing up via the GUI to the local drive or NAS device, no problems.
2. when backing up via Query Analyzer, process never ends.
3. when backing up via a SQL Server Agent job, process never ends.
In the last example that you provided, where does <AUTO> point to?
Do you encounter the same problems if you backup using the command line e.g.
sqlbackupc -sql "BACKUP DATABASE northwind to DISK = '<somewhere>'"
Are you using SQL 2000 with SP3 or later applied?
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
<auto> points to \MSSQL\Backup on the local server
I will try the command line today.
Yes, we are running SQL Server Enterprise Edition w/ SP4. Here is my version:
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
May 3 2005 23:18:38
Copyright (c) 1988-2003 Microsoft Corporation
Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
Also, I have read on this site that I need access to application data directory with the logs. Currently I do not have this access. Also when I schedule the jobs, I schedule them as myself or sa - both of which have sysadmin privileges.
C:\Program Files\Red Gate\SQL Backup>SQLBackupC -E -SQL "BACKUP DATABASE ImportD
B TO DISK = 'D:\MSSQL\Backup\RedGateTest.sqb'
SQL Backup 3.2.0, (c) Red Gate Software Ltd 2004 - 2005
Serial number: <removed>
Backing up ImportDB (full database) to \MSSQL\Backup\RedGateTest.sqb ...
Backup data size : 284.875 MB
Compressed data size: 85.539 MB
Compression rate : 69.97%
Process completed successfully.
Processed 36368 pages for database 'ImportDB', file 'ImportDB_Data' on file 1.
Processed 1 pages for database 'ImportDB', file 'ImportDB_Log' on file 1.
BACKUP DATABASE successfully processed 36369 pages in 16.650 seconds (17.893 MB/
sec).
(1 row affected)
Any ideas?
If that fails, then the problem lies in the extended stored procedure.
In an earlier post, you mentioned that the backup tasks start, the sqb files get created but the job never ends. What were the size of the sqb files? Were they 0 bytes, or somewhere close to a size you expect them to be?
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Output from SQL Backup (3.2.0)
SQL Backup 3.2.0, (c) Red Gate Software Ltd 2004 - 2005
Serial number: < removed >
Backing up ImportDB (full database) to \MSSQL\Backup\RedGateTest.sqb ...
Backup data size : 284.875 MB
Compressed data size: 85.539 MB
Compression rate : 69.97%
Process completed successfully.
Processed 36368 pages for database 'ImportDB', file 'ImportDB_Data' on file 1.
Processed 1 pages for database 'ImportDB', file 'ImportDB_Log' on file 1.
BACKUP DATABASE successfully processed 36369 pages in 16.379 seconds (18.189 MB/sec).
(1 row affected)
(11 row(s) affected)
The never-ending jobs created sqb files of the expected size (e.g., 87MB when using the UI and 87MB when using the job).
Re the failures, are they are entries in the Windows application logs (when viewed via the Event Viewer)?
And I also forgot to ask: what version of SQL Backup are you using (3.2.0.1 or later)?
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Re failures - nothing is nothing in the Windows application logs.
I am using version 3.2.01.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
===
DECLARE @success int
EXEC @success=master..sqlbackup '-SQL "BACKUP DATABASE [MyDB]
TO DISK = [\\MyNas\MyDB.sqb] "
WITH NAME = "MyDB Database",
DESCRIPTION = "Database: MyDB Instance: (local) Server: Production",
INIT, COMPRESSION = 1" -E'
/* SQLBackup returns 0 for failure and 1 for success */
IF @success=0
BEGIN
RAISERROR('Backup Failed', 16,1)
END
===
Below is the restore code which has been relatively problem.
DECLARE @success int
EXEC @success=master..sqlbackup '-SQL "RESTORE DATABASE [MyDB]
FROM DISK = [\\MyNas\MyDB.sqb] "
WITH RECOVERY,
REPLACE,
MOVE "MyDB" TO "D:\MSSQL\Data\MyDB.mdf",
MOVE "MyDB_log" TO "D:\mssql\data\MyDB_log.ldf" -E'
/* SQLBackup returns 0 for failure and 1 for success */
IF @success=0
BEGIN
RAISERROR('Restore Failed', 16,1)
END
After all this, I think all is well now. Thanks for all your help.