Showing posts with label admin. Show all posts
Showing posts with label admin. Show all posts

Sunday, March 25, 2012

Backup solution - question about transaction log

I've just inherited (i.e., our sys admin / DBA left the company) a fairly small SQL Server that's running 7 production databases. Most are quite small, but there are two which are about 40gb each. Traffic is quite low - ~30-40 users at one time doing your basic SELECT / UPDATE / INSERT stuff.

Anyway, I was going through some of the backups jobs and noticed that the transaction logs for each database were absolutely huge (in some cases bigger than the DB itself) which led me to think the log wasn't getting truncated.

The T-SQL being run in each case was

Currently, the transaction log for 6 DBs is backed up 3 times a day (and the 7th, "mission critical" DB is backed up every 15 minutes) with the following T-SQL:

BACKUP LOG <database> to <device> WITH NOINIT, NOFORMAT, NOSKIP, NOUNLOAD

5 of the 7 databases get a full backup twice a day, with the 2 larger ones getting a differential, with e.g.,

BACKUP DATABASE <database> TO <device> WITH NOINIT , NOUNLOAD , NAME = N'db', NOSKIP , STATS = 10, DESCRIPTION = N'db', NOFORMAT , MEDIANAME = N'db'DECLARE @.i INT
select @.i = position from msdb..backupset where database_name='db'and type!='F' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name='db')
RESTORE VERIFYONLY FROM <device> WITH FILE = @.i

This is then backed up to tape each night.

Looking through the documentation, those WITH commands are largely the default settings so I'm not sure why they're specified explicitly.

If I issue a

BACKUP LOG <database> to <device> WITH INIT, SKIP

then the log does get truncated. However, could someone explain the implications of that for me? As I understand it, INIT will overwrite any existing sets in the device, but considering that it will always backup anything that hasn't been committed then should it be a problem?

Alternatively could someone perhaps explain why the log wasn't getting truncated? It is my understanding that this should happen every time a full backup is completed... which is twice a day. Or does the Transaction log need to be manually shrunk every now and then?

Also, I understand the DECLARE... part in the last part of that DB backup SQL, but is it at all necessary?

Finally, does this backup strategy seem viable? Any thoughts and comments are appreciated!
Matt

By default in the backup database command if you do not specify anything it will append ,eg...

backup database xxxx to disk='F:\test\xxxx.bak' and check the bak file size

now again reissue the same command,

backup database xxxx to disk='F:\test\xxxx.bak' and once again check the bak file size.......it will be double the size

next time issue the same command using WITH INIT option,

backup database xxxx to disk='F:\test\xxxx.bak' WITH INIT now see the bak file size it will be the same size as in 1st case.........if you do not specify anything SQL server will use the default With NOINIT option..........so you need to specify them explicitly if you needed to overwrite........

the log gets truncated if you specify the command,

backup log dbname with truncate_only.........this command will be depreciated in future versions........once you issue this comand, all the committed transactions will be rolled forward and written to data file and uncommitted trans will be rolled back.......

since you have a mission critical db i suggest you go for Log shipping or Database mirroring in sql 2005.........instead of relying on your db backups.........if you have sufficient disk space go for full backup and if you feel the db is important and if you want to have db consistency you can have tran log backups and differential backups else not required........

|||Am I right about when the transaction log should get truncated - i.e., on a full database backup?|||

You are right, that the transaction log should be truncated after a full backup. However, note that the contents of the log will be truncated and the physical file will maintain its size. Therefore, you may see a large transaction log file although it won't be full. In order to reduce the size of the file, you'll need to run some form of SHRINKFILE operation.

HTH!

Sunday, March 11, 2012

Backup Planning assistance

Hi all,

New to database admin and I am attempting to work out a god backup schedule.

The database is a failry critical system so minimal downtime and dataloss from failure is the key to this.

Assuming storage is not an issue for me can anyone add some help.

What I was planning was a full backup an Sunday night and Wednesday nights at 6pm using

'backup database helpdesk to BK1 with noformat, init, stats'

Differential backups each night at 6pm using

'backup database helpdesk to BK1 with differential, noformat, noinit, stats'

Then a transaction log backup every 4 hours during the day with ??

'backup log helpdesk to Bk1 with ??

This is the part I am stuck on...

Firstly should all backups be going to the same logical backup device? in this case BK1 which points to a network share or should each go to a different location?

And what switches should I be using with the TL backup?

If anyone has a good backup T-SQL script they use I would really appreciate some help.

Cheers
MarkMark

When you say minimal downtime - do you mean when the backup is being taken or on recovery of the database?

I always take the method of keeping the backup strategy as simple as possible. I personally would take a complete backup every night (if you have enoght time - ie not a 24 hour operation) and trans log backups as you see fit. This can all be set up via Enterpise Manager very easily.

As for where to store - depends on what type of crash you wish to recover from - at the extreme level thay need to be stored on external media (eg tape) so that they may be restored on another server.|||Mark

When you say minimal downtime - do you mean when the backup is being taken or on recovery of the database?

I always take the method of keeping the backup strategy as simple as possible. I personally would take a complete backup every night (if you have enoght time - ie not a 24 hour operation) and trans log backups as you see fit. This can all be set up via Enterpise Manager very easily.

As for where to store - depends on what type of crash you wish to recover from - at the extreme level thay need to be stored on external media (eg tape) so that they may be restored on another server.|||Thanks for the reply,

When I said down time I did mean time to recover, so you are correct.

I think I will take your advise and do a fullbackup each night. Cheers

Saturday, February 25, 2012

Backup of a MS SQL 2000 DB

Hi

I'm not really a MS SQL Admin. I have only one
system in our house holding an MS SQL DB.

I need to made a backup of the DB.
Can someone tell me what is the cheapest way?
To buy Backup Exec is not an option.

And I can't shut down the service while the backup is
running...

Regards and thanks in advance

Dominik"Dominik Hirt" <removethis.dhi@.dhi.chwrote in message
news:tCWHh.183311$_X1.48044@.fe05.news.easynews.com ...

Quote:

Originally Posted by

Hi
>
I'm not really a MS SQL Admin. I have only one
system in our house holding an MS SQL DB.
>
I need to made a backup of the DB.
Can someone tell me what is the cheapest way?
To buy Backup Exec is not an option.
>


Use QUERY Analyzer and look up details BACKUP DATABASE

You'll want something like BACKUP DATABASE 'foo' to
disk='\\remoteserver\share1\backupfilename.bak'

If your database is in full recovery mode, make sure to do a log backup also
on a regular basis.

And you can schedule backups also which is a good idea.

And all this can be done while the server is on line.

Quote:

Originally Posted by

And I can't shut down the service while the backup is
running...
>
Regards and thanks in advance
>
Dominik


--
Greg Moore
SQL Server DBA Consulting
sql (at) greenms.com http://www.greenms.com|||On Thu, 08 Mar 2007 16:36:50 GMT, "Greg D. Moore \(Strider\)"
<mooregr_deleteth1s@.greenms.comwrote:

Quote:

Originally Posted by

>And all this can be done while the server is on line.


To be more specific, all this can ONLY be donw while the server is on
line.

Roy Harvey
Beacon Falls, CT|||"Roy Harvey" <roy_harvey@.snet.netwrote in message
news:0lh0v2pam34rqi0ps0sra9p5snboj68knn@.4ax.com...

Quote:

Originally Posted by

On Thu, 08 Mar 2007 16:36:50 GMT, "Greg D. Moore \(Strider\)"
<mooregr_deleteth1s@.greenms.comwrote:
>

Quote:

Originally Posted by

>>And all this can be done while the server is on line.


>
To be more specific, all this can ONLY be donw while the server is on
line.
>
Roy Harvey
Beacon Falls, CT


True, but I was answering his specific question to that effect. I probably
should have been more clear in that regard.

--
Greg Moore
SQL Server DBA Consulting
sql (at) greenms.com http://www.greenms.com|||Greg D. Moore (Strider) schrieb:

Quote:

Originally Posted by

Use QUERY Analyzer and look up details BACKUP DATABASE
>
You'll want something like BACKUP DATABASE 'foo' to
disk='\\remoteserver\share1\backupfilename.bak'
>
If your database is in full recovery mode, make sure to do a log backup also
on a regular basis.
>
And you can schedule backups also which is a good idea.
>
And all this can be done while the server is on line.


Many thanks. That worked for me.

Dominik|||"Dominik Hirt" <removethis.dhi@.dhi.chwrote in message
news:DPtJh.220196$Wn.61860@.fe06.news.easynews.com. ..

Quote:

Originally Posted by

Greg D. Moore (Strider) schrieb:

Quote:

Originally Posted by

>Use QUERY Analyzer and look up details BACKUP DATABASE
>>
>You'll want something like BACKUP DATABASE 'foo' to
>disk='\\remoteserver\share1\backupfilename.bak'
>>
>If your database is in full recovery mode, make sure to do a log backup
>also on a regular basis.
>>
>And you can schedule backups also which is a good idea.
>>
>And all this can be done while the server is on line.


>
Many thanks. That worked for me.
>
Dominik


Welcome. Glad I could help.

--
Greg Moore
SQL Server DBA Consulting
Email: sql (at) greenms.com http://www.greenms.com

Thursday, February 16, 2012

Backup location

From backupset table in msdb we found that there is a baclup done by user 'NT
AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
Also how do i fnd physical location of above backup if it was done on DISK
Thanks
Yes it was done as the local sys admin account. Take a look at the system
table "backupfile" for that information.
Andrew J. Kelly SQL MVP
"Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
> From backupset table in msdb we found that there is a baclup done by user
> 'NT
> AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
> Also how do i fnd physical location of above backup if it was done on DISK
> Thanks
>
|||FYI, all backup and restore information is stored in the MSDB database.
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
I support the Professional Association for SQL Server
www.sqlpass.org
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:uaTlFca$EHA.1260@.TK2MSFTNGP12.phx.gbl...
> Yes it was done as the local sys admin account. Take a look at the
system[vbcol=seagreen]
> table "backupfile" for that information.
> --
> Andrew J. Kelly SQL MVP
>
> "Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
> news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
user[vbcol=seagreen]
DISK
>
|||I would like to know where i can find the file *.bak which i could use to
restore the database ?
I looked at following tables and couldnt find it
backupset
backupfile
backupmediaset
Thanks..
"Geoff N. Hiten" wrote:

> FYI, all backup and restore information is stored in the MSDB database.
> --
> Geoff N. Hiten
> Microsoft SQL Server MVP
> Senior Database Administrator
> Careerbuilder.com
> I support the Professional Association for SQL Server
> www.sqlpass.org
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:uaTlFca$EHA.1260@.TK2MSFTNGP12.phx.gbl...
> system
> user
> DISK
>
>
|||You can get the device from the physical_device_name column
in the table backupmediafamily
-Sue
On Tue, 18 Jan 2005 14:55:06 -0800, Sanjay
<Sanjay@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>I would like to know where i can find the file *.bak which i could use to
>restore the database ?
>I looked at following tables and couldnt find it
>backupset
>backupfile
>backupmediaset
>Thanks..
>
>"Geoff N. Hiten" wrote:

Backup location

From backupset table in msdb we found that there is a baclup done by user 'NT
AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
Also how do i fnd physical location of above backup if it was done on DISK
ThanksYes it was done as the local sys admin account. Take a look at the system
table "backupfile" for that information.
--
Andrew J. Kelly SQL MVP
"Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
> From backupset table in msdb we found that there is a baclup done by user
> 'NT
> AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
> Also how do i fnd physical location of above backup if it was done on DISK
> Thanks
>|||FYI, all backup and restore information is stored in the MSDB database.
--
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
I support the Professional Association for SQL Server
www.sqlpass.org
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:uaTlFca$EHA.1260@.TK2MSFTNGP12.phx.gbl...
> Yes it was done as the local sys admin account. Take a look at the
system
> table "backupfile" for that information.
> --
> Andrew J. Kelly SQL MVP
>
> "Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
> news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
> > From backupset table in msdb we found that there is a baclup done by
user
> > 'NT
> > AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
> >
> > Also how do i fnd physical location of above backup if it was done on
DISK
> >
> > Thanks
> >
>|||I would like to know where i can find the file *.bak which i could use to
restore the database ?
I looked at following tables and couldnt find it
backupset
backupfile
backupmediaset
Thanks..
"Geoff N. Hiten" wrote:
> FYI, all backup and restore information is stored in the MSDB database.
> --
> Geoff N. Hiten
> Microsoft SQL Server MVP
> Senior Database Administrator
> Careerbuilder.com
> I support the Professional Association for SQL Server
> www.sqlpass.org
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:uaTlFca$EHA.1260@.TK2MSFTNGP12.phx.gbl...
> > Yes it was done as the local sys admin account. Take a look at the
> system
> > table "backupfile" for that information.
> >
> > --
> > Andrew J. Kelly SQL MVP
> >
> >
> > "Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
> > news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
> > > From backupset table in msdb we found that there is a baclup done by
> user
> > > 'NT
> > > AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
> > >
> > > Also how do i fnd physical location of above backup if it was done on
> DISK
> > >
> > > Thanks
> > >
> >
> >
>
>|||You can get the device from the physical_device_name column
in the table backupmediafamily
-Sue
On Tue, 18 Jan 2005 14:55:06 -0800, Sanjay
<Sanjay@.discussions.microsoft.com> wrote:
>I would like to know where i can find the file *.bak which i could use to
>restore the database ?
>I looked at following tables and couldnt find it
>backupset
>backupfile
>backupmediaset
>Thanks..
>
>"Geoff N. Hiten" wrote:
>> FYI, all backup and restore information is stored in the MSDB database.
>> --
>> Geoff N. Hiten
>> Microsoft SQL Server MVP
>> Senior Database Administrator
>> Careerbuilder.com
>> I support the Professional Association for SQL Server
>> www.sqlpass.org
>> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
>> news:uaTlFca$EHA.1260@.TK2MSFTNGP12.phx.gbl...
>> > Yes it was done as the local sys admin account. Take a look at the
>> system
>> > table "backupfile" for that information.
>> >
>> > --
>> > Andrew J. Kelly SQL MVP
>> >
>> >
>> > "Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
>> > news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
>> > > From backupset table in msdb we found that there is a baclup done by
>> user
>> > > 'NT
>> > > AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
>> > >
>> > > Also how do i fnd physical location of above backup if it was done on
>> DISK
>> > >
>> > > Thanks
>> > >
>> >
>> >
>>

Backup location

From backupset table in msdb we found that there is a baclup done by user 'N
T
AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
Also how do i fnd physical location of above backup if it was done on DISK
ThanksFYI, all backup and restore information is stored in the MSDB database.
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
I support the Professional Association for SQL Server
www.sqlpass.org
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:uaTlFca$EHA.1260@.TK2MSFTNGP12.phx.gbl...
> Yes it was done as the local sys admin account. Take a look at the
system
> table "backupfile" for that information.
> --
> Andrew J. Kelly SQL MVP
>
> "Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
> news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
user[vbcol=seagreen]
DISK[vbcol=seagreen]
>|||I would like to know where i can find the file *.bak which i could use to
restore the database ?
I looked at following tables and couldnt find it
backupset
backupfile
backupmediaset
Thanks..
"Geoff N. Hiten" wrote:

> FYI, all backup and restore information is stored in the MSDB database.
> --
> Geoff N. Hiten
> Microsoft SQL Server MVP
> Senior Database Administrator
> Careerbuilder.com
> I support the Professional Association for SQL Server
> www.sqlpass.org
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:uaTlFca$EHA.1260@.TK2MSFTNGP12.phx.gbl...
> system
> user
> DISK
>
>|||You can get the device from the physical_device_name column
in the table backupmediafamily
-Sue
On Tue, 18 Jan 2005 14:55:06 -0800, Sanjay
<Sanjay@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>I would like to know where i can find the file *.bak which i could use to
>restore the database ?
>I looked at following tables and couldnt find it
>backupset
>backupfile
>backupmediaset
>Thanks..
>
>"Geoff N. Hiten" wrote:
>|||Yes it was done as the local sys admin account. Take a look at the system
table "backupfile" for that information.
Andrew J. Kelly SQL MVP
"Sanjay" <Sanjay@.discussions.microsoft.com> wrote in message
news:32A9F457-BC22-497C-BE68-5DB7FE753ACE@.microsoft.com...
> From backupset table in msdb we found that there is a baclup done by user
> 'NT
> AUTHORITY/SYSTEM' does it mean that a local admin is doing backups
> Also how do i fnd physical location of above backup if it was done on DISK
> Thanks
>