Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Full Database Backup with no truncate Expand / Collapse
Author
Message
Posted Sunday, November 18, 2012 11:23 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 2:29 AM
Points: 2, Visits: 13
Hello!
I need write tsql statement for full database backup without truncate log
Please Help
Post #1386163
Posted Monday, November 19, 2012 12:17 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 29, 2014 5:52 AM
Points: 369, Visits: 1,215
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
Post #1386178
Posted Monday, November 19, 2012 12:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 2:29 AM
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?
Post #1386181
Posted Monday, November 19, 2012 12:59 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, November 21, 2014 8:48 AM
Points: 323, Visits: 986
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)





-----------------------------------------------------------------------------
संकेत कोकणे
Post #1386193
Posted Monday, November 19, 2012 2:05 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 29, 2014 5:52 AM
Points: 369, Visits: 1,215
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
Post #1386219
Posted Monday, November 19, 2012 2:16 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 29, 2014 5:52 AM
Points: 369, Visits: 1,215
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
Post #1386232
Posted Monday, November 19, 2012 2:19 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 1:14 PM
Points: 40,615, Visits: 37,081
Of course, shrinking a log is not something that should be regularly done.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1386236
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse