SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Full Database Backup with no truncate


Full Database Backup with no truncate

Author
Message
alex_zilberman
alex_zilberman
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 13
Hello!
I need write tsql statement for full database backup without truncate log
Please Help
Vedran Kesegic
Vedran Kesegic
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1894 Visits: 1266
Why, what are you trying to achieve?
Full and differential backup does not truncate transaction log, it is (almost) independent. Transaction log backup command can truncate transaction log, and usually is desired behavior in full recovery model.
Documentation might help: http://msdn.microsoft.com/en-us/library/ms186865.aspx
Or a good tutorial about sql server backup.

_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths

alex_zilberman
alex_zilberman
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 13
The recovery model is: simple

also

I write the statement something like this:
Backup Database [db name]
to disk = N'Path to file'
with init, Name=N'full database backup', skip, stats=10;

Is this will not truncate the log and if it do , what statement will do work that I need?
sanket kokane
sanket kokane
SSC Eights!
SSC Eights! (819 reputation)SSC Eights! (819 reputation)SSC Eights! (819 reputation)SSC Eights! (819 reputation)SSC Eights! (819 reputation)SSC Eights! (819 reputation)SSC Eights! (819 reputation)SSC Eights! (819 reputation)

Group: General Forum Members
Points: 819 Visits: 1022
alex_zilberman (11/19/2012)
The recovery model is: simple

also

I write the statement something like this:
Backup Database [db name]
to disk = N'Path to file'
with init, Name=N'full database backup', skip, stats=10;

Is this will not truncate the log and if it do , what statement will do work that I need?



why you are worrying about truncate_log when you are using simple recovery model ?

log get truncated every time checkpoint occur in simple recovery model . (Please anyone correct me if I'm wrong)

-----------------------------------------------------------------------------
संकेत कोकणे
Vedran Kesegic
Vedran Kesegic
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1894 Visits: 1266
Log truncation does not shrink the file size, it just marks the parts of the log file free for reuse. You have to explicitly shrink the log file. Don't shrink to a size that is smaller than usual log size for that DB (e.g. 1 GB), because you will waist IO by needless shrinking and growing back to normal size.
In simple recovery model there are two conditions that transaction log (VLF = virtual log file, a logical unit of a transaction log that can be marked for reuse) is truncated:

1) there are no active (uncommitted) transactions in that VLF
2) CHECKPOINT has occurred

In full recovery model there is one more condition:
3) log backup has occurred

In simple recovery model your log will grow e.g. if you have a very long transaction that heavily modified the db.

HTH,
Vedran

_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths

Vedran Kesegic
Vedran Kesegic
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1894 Visits: 1266
alex_zilberman (11/19/2012)

Is this will not truncate the log and if it do , what statement will do work that I need?

No, backup will not truncate the log, nor it will shrink the log file.
This will shrink the log file if conditions from my previous post are met:

-- find logical name of the log file
sp_helpdb 'MyDbName'

-- Shrink the log to 1000 MB
CHECKPOINT
DBCC SHRINKFILE('MyTransactionLog', 1000)



This could also be useful:

-- log file size and percentage free
DBCC SQLPERF (LOGSPACE)

-- Why the log is not truncated
select name, log_reuse_wait_desc, recovery_model_desc from sys.databases

-- oldest active transaction
DBCC OPENTRAN



HTH,
Vedran

_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths

GilaMonster
GilaMonster
SSC Guru
SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)

Group: General Forum Members
Points: 218621 Visits: 46278
Of course, shrinking a log is not something that should be regularly done.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search