| Author |
Topic |
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-04-19 : 16:26:48
|
| In EM my transaction log shows the red icon saying the job failed but I notice that the files are written to disk. I backup the log to another server using a UNC path.I really need the help.All help appreciated. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-19 : 16:39:41
|
| What does the SQL Server Error Log show at the time that the backup ran? Is this backup being done through a maintenance plan or through the explicit BACKUP command? If through a maintenance plan, please let us know what options you have checked.Tara |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2004-04-19 : 16:47:43
|
| Are you attempting to perform a tlog backup on a database that is not in FULL mode?-ec |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-04-19 : 17:04:41
|
| The SQL log shows the file being written, extract-2004-04-19 15:51:03.58 backup Log backed up: Database: DBNAME, creation date(time): 2004/03/18(10:26:05), first LSN: 1764:403:1, last LSN: 1764:403:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {'\\server_name\path_name\sql_instance\DBNAME\DBNAME_tlog_200404191551.TRN'}).a) The backup is done thru a maintenance plan. b) The options are remove files older than 2 days; run every 10 minutes from 8:00am to 10:00pm; write to disk using UNC path; verify integrity after backup; use subdirectories.EyechartThe master,msdb and tempdb database recovery model is set to simple, all other databases are set to full.All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-19 : 17:07:27
|
| Eeks, why are you writing the file to a UNC path? This is not recommended. Backups are so important that you can't afford to have a network problem occur during a backup. So it is recommended that you backup to local disk first, then copy the file to the UNC path or to tape. So what happens with your job when you write to local disk instead? If you don't get an error, you can assume that the problem is with the UNC path. If you do get the error still, I would run SQL Profiler while the backup is running to capture the command that the maintenance plan is using and then run that same command inside Query Analyzer.Tara |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-04-20 : 15:50:07
|
| I choose the default directory and it still failed. I notice this is happening to more of my servers where the tlog backup is failing.All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-20 : 15:58:03
|
| What happens when you run the command in Query Analyzer?Tara |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-04-20 : 16:35:34
|
| the result is :(129 row(s) affected)Server: Msg 22029, Level 16, State 1, Line 0sqlmaint.exe failed.All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-20 : 16:39:55
|
| No, when you run the BACKUP LOG command in Query Analyzer.And what command did you run in Query Analyzer to get that sqlmaint.exe failed error?Tara |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-04-20 : 16:59:58
|
| the query I ran in QA wasEXECUTE master.dbo.xp_sqlmaint N'-PlanID 03181367-E5DA-4BBA-AB5F-23B9AA2BFD5D -WriteHistory -VrfyBackup -BkUpMedia DISK -BkUpLog -UseDefDir -DelBkUps 2DAYS -CrBkSubDir -BkExt "TRN"'When I run a backup log db name to disk='' , I get BACKUP LOG successfully processed 0 pages in 0.041 seconds (0.000 MB/sec).All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-20 : 17:08:00
|
I would suggest recreating the database maintenance plan. I would verify that you have enough disk space and that the files are being deleted after two days. I ultimately would suggest not using the database maintenance plan to create your database maintenance jobs. You wouldn't use a wizard to create an application, so don't use one in SQL. You can write much more powerful code if you use pure T-SQL. Here is an example backup stored proc that I have:SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GO------------------------------------------------------------------------------------------------------ OBJECT NAME : isp_FullBackup_UserDBs---- AUTHOR : Tara Duggan-- DATE : December 18, 2003---- INPUTS : @Path - location of the backups-- OUTPUTS : None-- DEPENDENCIES : None---- DESCRIPTION : This stored procedure performs a full backup on all of the user databases---- EXAMPLES (optional) : EXEC isp_FullBackup_UserDBs @Path = 'C:\MSSQL\Backup\'---- MODIFICATION HISTORY :------------------------------------------------------------------------------------------------------ ----------------------------------------------------------------------------------------------------ALTER PROC isp_FullBackup_UserDBs(@Path VARCHAR(100))ASSET NOCOUNT ONDECLARE @Now CHAR(14) -- current date in the form of yyyymmddhhmmssDECLARE @DBName SYSNAME -- stores the database name that is currently being processedDECLARE @SQL VARCHAR(7000) -- stores the dynamically created xp_backup_database commandDECLARE @cmd SYSNAME -- stores the dynamically created DOS commandDECLARE @Result INT -- stores the result of the dir DOS commandDECLARE @RowCnt INT -- stores @@ROWCOUNT-- Get the list of the databases to be backed up, does not include master, model, msdb, tempdb, Northwind, or pubsSELECT nameINTO #WhichDatabaseFROM master.dbo.sysdatabasesWHERE name NOT IN ('master', 'model', 'msdb', 'pubs', 'tempdb', 'Northwind')ORDER BY name-- Get the database to be backed upSELECT TOP 1 @DBName = nameFROM #WhichDatabaseSET @RowCnt = @@ROWCOUNT-- Iterate throught the temp table until no more databases need to be backed upWHILE @RowCnt <> 0BEGIN -- Get the current date using style 120, remove all dashes, spaces, and colons SELECT @Now = REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(50), GETDATE(), 120), '-', ''), ' ', ''), ':', '') -- Build the dir command that will check to see if the directory exists SELECT @cmd = 'dir ' + @Path + @DBName -- Run the dir command, put output of xp_cmdshell into @result EXEC @result = master.dbo.xp_cmdshell @cmd -- If the directory does not exist, we must create it IF @result <> 0 BEGIN -- Build the mkdir command SELECT @cmd = 'mkdir ' + @Path + @DBName -- Create the directory EXEC master.dbo.xp_cmdshell @cmd, NO_OUTPUT END -- The directory exists, so let's delete files older than two days ELSE BEGIN -- Stores the name of the file to be deleted DECLARE @WhichFile VARCHAR(1000) CREATE TABLE #DeleteOldFiles ( DirInfo VARCHAR(7000) ) -- Build the command that will list out all of the files in a directory SELECT @cmd = 'dir ' + @Path + @DBName + ' /OD' -- Run the dir command and put the results into a temp table INSERT INTO #DeleteOldFiles EXEC master.dbo.xp_cmdshell @cmd -- Delete all rows from the temp table except the ones that correspond to the files to be deleted DELETE FROM #DeleteOldFiles WHERE ISDATE(SUBSTRING(DirInfo, 1, 10)) = 0 OR DirInfo LIKE '%<DIR>%' OR SUBSTRING(DirInfo, 1, 10) >= GETDATE() - 2 -- Get the file name portion of the row that corresponds to the file to be deleted SELECT TOP 1 @WhichFile = SUBSTRING(DirInfo, LEN(DirInfo) - PATINDEX('% %', REVERSE(DirInfo)) + 2, LEN(DirInfo)) FROM #DeleteOldFiles SET @RowCnt = @@ROWCOUNT -- Interate through the temp table until there are no more files to delete WHILE @RowCnt <> 0 BEGIN -- Build the del command SELECT @cmd = 'del ' + @Path + + @DBName + '\' + @WhichFile + ' /Q /F' -- Delete the file EXEC master.dbo.xp_cmdshell @cmd, NO_OUTPUT -- To move to the next file, the current file name needs to be deleted from the temp table DELETE FROM #DeleteOldFiles WHERE SUBSTRING(DirInfo, LEN(DirInfo) - PATINDEX('% %', REVERSE(DirInfo)) + 2, LEN(DirInfo)) = @WhichFile -- Get the file name portion of the row that corresponds to the file to be deleted SELECT TOP 1 @WhichFile = SUBSTRING(DirInfo, LEN(DirInfo) - PATINDEX('% %', REVERSE(DirInfo)) + 2, LEN(DirInfo)) FROM #DeleteOldFiles SET @RowCnt = @@ROWCOUNT END DROP TABLE #DeleteOldFiles END -- Build the xp_backup_database command dynamically SELECT @SQL = '' SELECT @SQL = @SQL + 'BACKUP DATABASE ' + @DBName + '' + CHAR(10) SELECT @SQL = @SQL + 'TO DISK = ''' + @Path + @DBName + '\' + @DBName + '_' + @Now + '.BAK''' + CHAR(10) SELECT @SQL = @SQL + 'WITH INIT ' + CHAR(10) -- Backup the database using xp_backup_database EXEC (@SQL) -- To move onto the next database, the current database name needs to be deleted from the temp table DELETE FROM #WhichDatabase WHERE name = @DBName -- Get the database to be backed up SELECT TOP 1 @DBName = name FROM #WhichDatabase SET @RowCnt = @@ROWCOUNT -- Let the system rest for 5 seconds before starting on the next backup WAITFOR DELAY '00:00:05'ENDDROP TABLE #WhichDatabaseSET NOCOUNT OFFRETURNGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GOTara |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-04-21 : 11:43:44
|
| Thank Tara, I am going through and making myself confortable with the script.What method is best for transfering the backup files from the local server to another server. I was thinking to use a batch file that was scheduled in the task scheduler in window.All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-21 : 12:29:59
|
| I would use a batch file scheduled inside SQL Server. But you can just add the execution of the batch file to your backup job using xp_cmdshell.Tara |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-04-23 : 11:04:39
|
| Why was a host variable of the form '#WhichDatabase' used and not a SQL variable like @whichdatabase?All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-04-23 : 12:23:03
|
| #WhichDatabase is a temporary table and not a variable. A variable can only stored one value at a time, while a temporary table can store table data.Tara |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-04-25 : 00:25:05
|
| Rohans, when you copy the database from one server to another, you ought to look at ftp or robocopy.exe instead of the standard copy command. The ftp and robocopy are much, much faster.Robocopy is easier to use. It's also free for download and included in the Windows Resource Kit.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-05-12 : 11:18:19
|
| Quick one. If I change the script above so that it does a backup of the logs how would it affect anything if at all. I did and it seemed OK, but doing a double check.All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-05-12 : 12:21:55
|
| That's good that you'll have one for tlogs as well.Tara |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-05-12 : 12:33:23
|
| Problems -The DB backup job seems not to run completely but I see no errors in the LOGS. I also don't see the BAK file it should write so I know it was not completed. How may I investigate this?All help appreciated. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-05-12 : 12:40:59
|
| Change EXEC (@SQL) to PRINT @SQL. Make sure it is creating the sql string correctly. You might want to print out @cmd as well before each execution of it, which I think is 3 times.Tara |
 |
|
|
rohans
Posting Yak Master
194 Posts |
Posted - 2004-05-12 : 12:45:26
|
| If I put that in the new stored proc will the commands be printed to the SQL LOG file?All help appreciated. |
 |
|
|
Next Page
|