Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

pre- post command to shrink sql transaction logs

Created: 28 Mar 2013 | 2 comments

Hi,

Ì`ve a problem, i habe a backupjob to backup the sql logs from a remote sql server, after this i shrink the transaction log files manual with a sql script directly on the sql server. What i want is the backupjob in be2012 should run the shrink job when the log backup is complete.

When i edit the backupjob, i can use the pre and post commands, i define a script with a path and fill into teh pre post commands. it doesn`t work. Maby i must use a specially syntax?

any idea?

 

Thank you

 

Operating Systems:

Comments 2 CommentsJump to latest comment

VJware's picture

Is this how added the post command for shrink

1) Create a script file with following content called test.sql

USE database_name
ALTER DATABASE database_name SET RECOVERY SIMPLE;
DBCC SHRINKFILE(logfile_name);
ALTER DATABASE database_name SET RECOVERY FULL;

Alternatively, you can set the script using these commands - http://msdn.microsoft.com/en-us/library/ms189493%2...

2) Then add the following line to the post command

sqlcmd -S sqlservername\instanceName -i C:\test.sql

Lykantroph's picture

Hi Vjware,

Thank you for your reply, i tryed this but it doesn`t work and i think its wrong.  When the pre post command in the be2012 job switch the database from the recovery full mode to simple mode, sql delete the logfile bevor the backup begin. When the backup is complete, the script switch back to the recovery full mode - sql create a transactionlog again.

i got the solution with the sql maintenance plan, who shrink the db logs. this task can export as script  and can use with the cmd command in the pre post command in a be job.

thank you

lykantroph