Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Full recovery and log shipping.

Author  Topic 

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 14:57:20
Can this be done? I'm thinking of a zillion ways maybe to set this up but just need a push in the right direction.

Production Server Maintenance plan causes....
Full Backup every night.
Transaction log backup every hour.

Log ship
Database Backup Full every night
Transaction log every half hour.

Now how do the two interact?
Can I ship the TRN's generated by the mainenance plan to the standby server.
Can I create the Maintenance plan such that it backs up to device so the logship backup uses the same file.

The general idea here is that the Maintenance plan in full recovery covers for database corruption while the log shipped server covers for the hardware failure.

I'd like to set it up so the Maintenance plan remains intact so our IT leader has a single point of administration. The Maintenance plan.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 14:59:41
I am not understanding. In a log shipping environment, you have two servers. The source server is your production server. It has a log shipping maintenance plan (if you are going to use the built-in log shipping in Ent. Edition) that does a full backup periodically and transaction log backups frequently. The plan copies the log files to the destination. The destination server is a standby server. It can only be used for read-only purposes (if you have it setup for this, otherwise it can't be used at all).

Given this information, what is your question?

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 15:24:50
Sorry, I was thinking SQL7.0 roll your own, I swear I typed it (SQL7.0)

SQL 7.0, so I can't see how I can maintain the unique file names.
See the little demo's I've seen show the BACKUP DATABASE and BACKUP LOG commands going to devices with INIT.(overwrite). So there exists only one of each at any given time. If I went to apply those out of EM it would work ok.
In the DB maintenance plan the automatic scripting of it accounts for the unique names of each .BAK or .TRN.(with dates)
but there is no option to go to device. So with log shipping you don't get a little tree (sequential transaction log backups. Because it is not needed but you are calling BACKUP LOG on the same databases as the Maintenance plan so they got to be stepping on each other.... more to come.... I'm really confused.


I just got to bust it up into smaller parts I think and attack each one individually. If this maintenance plan thing wasn't here it would make sense.

So what is my question?
If I make jobs to handle the full backup and transaction log backup with the intent of using them for log shipping how can I present them to someone in a maintenance plan?


Yeah that is it for sure cause the log shipping job
1.)Truncates the Transaction log. Which really doesn't happen here but will happen right after the next step...
2.)Backup database.(only one .BAK file allowed though can't leave yesterdays or four days worth on the server hanging around like in a maintenance plan)
3.)Each Tlog backup is performed without a truncate so the log remains complete until after the full backup(can this continuous log be applied to the last full backup? Like with a BACKUP LOG switch that says ignore last ten backups because they were lost so I need
all that you have)


Just thinking out loud here.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 16:20:45
quote:
Originally posted by Sitka

So what is my question?
If I make jobs to handle the full backup and transaction log backup with the intent of using them for log shipping how can I present them to someone in a maintenance plan?



You don't create a maintenance plan on the destination server. You have to create custom jobs that will perform the restores of the transaction log. Your job would figure out which file needs to be applied then apply it.

Here is some good info:

[url]http://www.sql-server-performance.com/sql_server_log_shipping.asp[/url]

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 16:52:33
That is the link I used to set this up.
quote:
You don't create a maintenance plan on the destination server.

no, I never did. I have no maintenance plan on the standby server. Just a couple procs that restore databases and logs.
The idea here is each time the backup log job runs on the live server it BACKUP's LOG with over write. So the maintenace plan does it's own BACKUP LOG
Do these remain totally exclusive of each other? I can't see how that can be. Because we are calling BACKUP LOG log on the same database.
So given the Maintenance plan and Log shipping job are working?
The log shipping job creates a Tlog backup to a device , overwrites a single file many times throughout the day...
and the maintenance plan makes for example 10 sequential transaction log backups, that remain available and are queued up in the restore
database wizard until a full backup is taken.



MAYBE.... look at it a different way.
What if I set my logshipping to full backup every hour, tlog backup every 2 minutes? What is the impact on a live server maintenance plan that goes full backup night, tlog every half hour. AND more importantly the recovery of that live server? Remember both are working the same database.

This isn't a nuts way of looking at it when you realize the DBMaintenance plan protects the Wizard bound Admin in case of media failure or foobar database. Whereas the standby server is at the ready in case of hardware failure, like a fried mobo or a whole in the roof. So the DBMaintenance plan should remain intact. I just can'r see the pieces of the puzzle that make that so. Because when you call backup or restore you are affecting what you are acting on.
Like Carlsberg's Principal the act of measuring changes that which is measured.


Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 17:01:09
Why do you want it to overwrite each time? Your log shipping could get out of sync. Take this for example:

Transaction backup at 2:00pm
Copy at 2:10 pm, but copy fails
Transaction backup at 2:30pm
Copy at 2:40pm, copy succeeds

Your destination server didn't get the 2pm log file, and it has been overwritten already. Your log shipping plan is now broken and you'll have to start with a full backup.

No the backups do not get queued up unless you are doing WITH NOINIT. Then you'll have multiple backups inside one file. Eventually, you'd need to do WITH INIT or your file would get huge.

Also, you should not have any other maintenance plans or jobs that are doing BACKUP LOG command. All logs need to be backed up by log shipping plan.

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 17:16:52
The steps/script in the job goes like this

1.)BACKUP LOG dbx TO dbx_log_backup_device WITH INIT, NO_TRUNCATE
WAITFOR DELAY '00:00:05'

2.)xcopy F:\MSSQL7\BACKUP\logshipping\dbx\dbx_log_backup_device.BAK \\admin1s2x\F$\MSSQL7\BACKUP\logshipping\dbx /c

3.)EXEC admin1s2x.master.dbo.restore_dbx_log_backup

where

CREATE PROCEDURE restore_dbx_log_backup AS
RESTORE LOG dbx
FROM DISK = 'F:\MSSQL7\BACKUP\logshipping\dbx\dbx_log_backup_device.BAK'
WITH
DBO_ONLY,
STANDBY = 'F:\MSSQL7\BACKUP\logshipping\dbx\undo_dbx_logship.ldf'
WAITFOR DELAY '00:00:05'
EXEC sp_dboption 'dbx', 'single user', true


The way I see that is that the log goes to the device and the device is a single file.
DOES that single file contain an assortment of TLog backups?. I wasn't aware? WITH INIT is there so I figured I was shipping a single transaction log backup. But yeah I don't know about your example where someone pulls the plug and you miss one.


Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 17:20:56
Yes the device has a single file. The file does not contain an assortment of TLog backups because it is using WITH INIT.

You should change the extensions of your files. Full backups should be BAK. TLogs should be LDF. Standby files should be DAT.

If ever your copy command fails, your log shipping will be out of sync.

Why the use of a backup device in the first place though? Do people use these anymore? I haven't used them since 6.5.

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 17:28:05
This one deserves it's own box

quote:
Also, you should not have any other maintenance plans or jobs that are doing BACKUP LOG command. All logs need to be backed up by log shipping plan.



exactly,

SOooooo ... A DBMAITENENCE plan creates an automated script that makes use of the named Tlog(xxx.TRN)backup files. You could ship
these too I guess If you could automate the naming but that isn't what the rest of the world recommends so I didn't do it.

Why would you want to?

Because just like I thought... then you said....then I quoted!!!!!

You are running BACKUP LOG in two different contexts.

How can the SERIALIZATION be maintained, when a DBMAINTENANCE PLAN is required as well as log shipping?

Feel free to answer that last one with "IT NEVER HAS TO BE!" just provide a little reason why.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 17:32:16
Actually you should have different names for the transaction logs that way they aren't overwritten. By overwriting them, you could cause log shipping to break if ever the copy fails.

A database maintenance plan is not required for log shipping. It just makes it easier to configure. You could do all of the work in jobs instead which is how Nigel and Brett have it in their environments.

I don't know what you mean by serialization be maintained. If you mean the order, then that's my point. The order could be wrong if the copy ever fails. You won't be able to recover from a failed copy because you've already overwritten the transaction log.

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 17:37:18
It's not that hard to see really, just picture it.
A nice shiny tower with a fancy wizard configured
maintenance plan.

Then some dirty little jobs passing files to a dirty
little server over in the corner.

Well things get messed up and the guy walks over to the shiny tower. Goes to EM and opens some tables and sees no records for all of 2002
Apparently this happened about an hour ago. OK get on the phone, and restore via right click with the little EM check boxes all except the last one. Fixed

Next week a fire breathing dragon comes in and desides to take the shinny tower and donate it to the methadone clinic.
Glad he left the other one. Just rename the Standby and at least we can buy a little time, until some new hardware is bought.
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 17:44:43
quote:
Actually you should have different names for the transaction logs that way they aren't overwritten. By overwriting them, you could cause log shipping to break if ever the copy fails.
I agree but can't really figure out how to do that.


quote:
A database maintenance plan is not required for log shipping

Exactly but in this case it is needed for the other ADMIN.

I'm saying wrt to serialization that two independent activities are going on.
The maintenance plan is doing backups as is the logshipping jobs on the same database in the same time span.
To me this looks broken......


And further you mentioned the order could be wrong if the copy ever fails. Well I Submit it is broken even if the copy never fails. Bbecause even though the order is correct the contents are wrong because the Tlog was backed up without the timing structure of the logshipping jobs by the DBMAINTENANCE PLAN or vice versa. How to fix?

Things that make you go Hmmmm.






Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 17:52:11
I understand what you mean about serialization. No it isn't broken. Log shipping doesn't use full backups. An initial database is restored using a full backup. After that, the maintenance plan takes over and only uses transaction log backups.

For the different names, you could put the system date and time in the file name. That is what others have done and that is what log shipping in SQL Server 2000 Ent. Edition does.

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 18:00:16
quote:

After that, the maintenance plan takes over and only uses transaction log backups.



The log shipping part runs now without a maintenanece plan. And if that is all that I needed to accomplish I could see an end.
But realise I need to maitain a working Maintenance plan on the live server. And like you said
Also, you should not have any other maintenance plans or jobs that are doing BACKUP LOG command. All logs need to be backed up by log shipping plan.

Thanks for this Tara. I'm just about to really break something, I better go
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 18:03:17
When I said maintenance plan, it could mean maintenance plan or a job that does copy and restore, which is what you have. A maintenance plan is just a series of T-SQL commands that get executed.

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-10 : 18:44:20
Yep, qut confusingf mi. For all who read this the maintnence plan was/shall be the one generated via the EM wizard.

nr will chime in here 'cause there has to be a reason he hates M(capital EM)aintenance plans.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-10 : 19:03:55
Reasons why not to use maintenance plans:

Because when they fail, the errors aren't helpful.
You don't know what they are doing behind the scenes.
Because they are created through wizards and wizards are for newbies
...

Tara
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-15 : 12:18:12
UPDATE;

Call me Tenacious O

I wouldn't give up, I convinced "them" to run one of our installs MSSQLSERVER and ...AGENT under a domain account. My Log shipping task just got a whole lot easier, along with a whole bunch of other things.

You got to fight, for the right, To PAAARRRR "T"



Tenacious O
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-11-17 : 11:50:13
Here is what I have figured out for
my SQL 7.0 log shipping. Boy did this get easy
once the SQL SERVICES were running under
Domain account. This handles a database
called userlist. All procs are master.dbo.

I was going to create this set for each database I need
failover on (probably will do all) then have a job to
run the full backups every night and the tran backups
every half hour. A couple of the databases are
pretty large (2 gig)
Figure once I get each set built
I can put all the Full Backups in a
single job with each step calling
ls_<database name>_backup

Run that nightly at 20:00 (tape kicks in at 00:00:01)

Second job will have a step for each
database calling
ls_<database name>_tlog

running every half hour 06:00 -> 18:00


Questions

1)
I'm a little unsure if I'm calling
DBO_ONLY
STANDBY
sp_dboption exactly as I should be
but it seems to work, they behave differently
on 2000 and 7
2)
does a person ship the master database?



LIVE SERVER - > @@servername = FRED

ALTER PROCEDURE ls_userlist_backup

AS SET NOCOUNT ON

BACKUP LOG userlist WITH TRUNCATE_ONLY
WAITFOR DELAY '00:00:05'

DECLARE @localdirectoryname nvarchar(128)
DECLARE @filename nvarchar(128)
DECLARE @fulllocalpath nvarchar(128)

SELECT @localdirectoryname = 'F:\LSBackup\'
SELECT @filename = 'userlist_' + CONVERT(CHAR(10),GETDATE(),110) + '_' + REPLACE(CONVERT(VARCHAR(5),GETDATE(),108), ':','') + '.bak'
SELECT @fulllocalpath = @localdirectoryname + @filename

BACKUP DATABASE userlist TO DISK = @fulllocalpath WITH INIT
WAITFOR DELAY '00:00:05'

DECLARE @cmd nvarchar(128)
SET @cmd = 'copy ' + @fulllocalpath + ' \\WILMA\F$\LSBackup'
EXEC master..xp_cmdshell @cmd , NO_OUTPUT
WAITFOR DELAY '00:00:05'

DECLARE @sourcefilenameout nvarchar(128)
SELECT @sourcefilenameout = @filename
EXEC WILMA.master.dbo.ls_userlist_backup_restore @sourcefilename = @sourcefilenameout



ALTER PROCEDURE ls_userlist_backup_tlog

AS SET NOCOUNT ON

DECLARE @localdirectoryname nvarchar(128)
DECLARE @filename nvarchar(128)
DECLARE @fulllocalpath nvarchar(128)

SELECT @localdirectoryname = 'F:\LSBackup\'
SELECT @filename = 'userlist_' + CONVERT(CHAR(10),GETDATE(),110) + '_' + REPLACE(CONVERT(VARCHAR(5),GETDATE(),108), ':','') + '.trn'
SELECT @fulllocalpath = @localdirectoryname + @filename

BACKUP LOG userlist TO DISK = @fulllocalpath WITH NO_TRUNCATE
WAITFOR DELAY '00:00:05'

DECLARE @cmd nvarchar(128)
SET @cmd = 'copy ' + @fulllocalpath + ' \\WILMA\F$\LSBackup'
EXEC master..xp_cmdshell @cmd , NO_OUTPUT
WAITFOR DELAY '00:00:05'


DECLARE @sourcefilenameout nvarchar(128)
SELECT @sourcefilenameout = @filename
EXEC WILMA.master.dbo.ls_userlist_backup_tlog_restore @sourcefilename = @sourcefilenameout






STANDBY SERVER - > @@servername = WILMA


ALTER PROCEDURE ls_userlist_backup_restore (@sourcefilename nvarchar(128))

AS SET NOCOUNT ON

DECLARE @fulllocalpath nvarchar(128)
SELECT @fulllocalpath = 'F:\LSBackup\' + @sourcefilename

RESTORE DATABASE userlist
FROM DISK = @fulllocalpath
WITH
DBO_ONLY,
REPLACE,
STANDBY = 'F:\LSBackup\undo_userlist_logship.ldf',
MOVE 'UserList_Data' TO 'F:\MSSQL7\data\UserList_data.mdf',
MOVE 'UserList_Log' TO 'D:\SQL-Logs\UserList_log.ldf'

WAITFOR DELAY '00:00:05'

EXEC sp_dboption 'userlist', 'single user', true


ALTER PROCEDURE ls_userlist_backup_tlog_restore (@sourcefilename nvarchar(128))

AS SET NOCOUNT ON

DECLARE @fulllocalpath nvarchar(128)
SELECT @fulllocalpath = 'F:\LSBackup\' + @sourcefilename

RESTORE LOG userlist
FROM DISK = @fulllocalpath
WITH
DBO_ONLY,
STANDBY = 'F:\LSBackup\undo_userlist_logship.ldf'

WAITFOR DELAY '00:00:05'

EXEC sp_dboption 'userlist', 'single user', true


CREATE PROCEDURE ls_userlist_recovery AS

RESTORE DATABASE userlist WITH RECOVERY
EXEC SP_DBOPTION 'userlist', 'read only', 'false'
EXEC SP_DBOPTION 'userlist', 'dbo use only', 'false'








Tenacious O
Go to Top of Page
   

- Advertisement -