Showing posts with label job. Show all posts
Showing posts with label job. Show all posts

Thursday, March 29, 2012

Backing up SQL Server MSDE and Express

We are attempting to backup using a maintenance plan a database to a network share.

The backup job works within a domain but fails within a workgroup?

Any thoughts?

thanks

hi Larry,

Larry Sitka wrote:

We are attempting to backup using a maintenance plan a database to a network share.

The backup job works within a domain but fails within a workgroup?

under which account does the maintenance plans run?

does the account running SQL Server have enought permissions on the remote network share? or the account on which the maintenance plan runs?

regards

Sunday, March 25, 2012

Backing up log when recovery set to Simple

I have a job that I created that backs up transaction logs on a server that has many databases on it. If a db recovery model is set to simple, I want the job to skip over that database, rather then trying to backup the log.

It would be easy to just let it try, and fail, however, the job status will show failed, even if it backs up all database logs, and only fails on one. Is there a way to easily programatically detect if a db is set to simple, and then I can skip backing up that db log?

Thanks
TommySELECT DATABASEPROPERTYEX('Northwind','Recovery')|||Thanks brett, that's what I needed, in case anyone else is interested, here's the syntax I'm using:

Declare @.Recovery_Model nvarchar(20),
Select @.Recovery_Model = CONVERT(nvarchar(20), DATABASEPROPERTYEX( @.Database_Name , 'Recovery' ))
if (@.Recovery_Model = 'SIMPLE')
PRINT 'Simple Mode so skip'
else
PRINT 'do the needful'

Backing up log file with a script setup as a job

Is there any way to include in this script below something
to tell the job to backup will the log file when it gets
to a certain percentage say 85%.
Thanks,
Aboki.
/* Script for backing up the transaction log when it is
getting full and clear the space for the log file. */
/* This can also apply to any other system but you need to
change drive and part location */
/* to match where backup location */
Backup LOG IntegraProd TO
DISK = 'D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\IntegraProdTran.bak'
GOYou could write a job to run every so often, which uses DBCC PERFLOG
to get information about log space and log space used. If log space for your
database is > 85% then issue your t-sql command.
The log is cyclic, it should wrap around and re-use empty space
where possible. It needs to keep information on the oldest active
transaction
for rollback. If your log is constantly at a certain size, this will most
likely be
right for the database anyway.
HTH
"Aboki" <waco361@.hotmail.com> wrote in message
news:08d801c3627b$37d262a0$a001280a@.phx.gbl...
> Is there any way to include in this script below something
> to tell the job to backup will the log file when it gets
> to a certain percentage say 85%.
> Thanks,
> Aboki.
>
> /* Script for backing up the transaction log when it is
> getting full and clear the space for the log file. */
> /* This can also apply to any other system but you need to
> change drive and part location */
> /* to match where backup location */
>
> Backup LOG IntegraProd TO
> DISK = 'D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\IntegraProdTran.bak'
> GO|||You can set an alert to start the job. There should be an example alert you
can modify already installed with SQL.
--
Geoff N. Hiten
SQL Server MVP
Senior Database Administrator
Careerbuilder.com
"Aboki" <waco361@.hotmail.com> wrote in message
news:08d801c3627b$37d262a0$a001280a@.phx.gbl...
> Is there any way to include in this script below something
> to tell the job to backup will the log file when it gets
> to a certain percentage say 85%.
> Thanks,
> Aboki.
>
> /* Script for backing up the transaction log when it is
> getting full and clear the space for the log file. */
> /* This can also apply to any other system but you need to
> change drive and part location */
> /* to match where backup location */
>
> Backup LOG IntegraProd TO
> DISK = 'D:\Program Files\Microsoft SQL
> Server\MSSQL\BACKUP\IntegraProdTran.bak'
> GOsql

Backing up DTS and SQL jobs....

I know If I store the DTS packages in SQL Server it will be stored in the
msdb database.
Also all the job scheduling information is stored in the msdb database.
Even though I am taking backup of system databases, I would like to know if
is there any way I can export all the DTS packages and jobs in any different
way. This is only an additional extra precaution incase If I am not able to
restore the system database in the event of disaster.
I am able to open the DTS packages individually and store as .dts file. It
is a time consuming process.
I am using SQL 2K.
Thanks,
J Smith
For DTS backup, I use a neat little program called, "DTS Backup 2000." It's
freeware.
"Jessy Martin" <Jessy_Smith79@.hotmail.com> wrote in message
news:uMDTg4gZFHA.3048@.TK2MSFTNGP14.phx.gbl...
>I know If I store the DTS packages in SQL Server it will be stored in the
> msdb database.
> Also all the job scheduling information is stored in the msdb database.
> Even though I am taking backup of system databases, I would like to know
> if
> is there any way I can export all the DTS packages and jobs in any
> different
> way. This is only an additional extra precaution incase If I am not able
> to
> restore the system database in the event of disaster.
> I am able to open the DTS packages individually and store as .dts file. It
> is a time consuming process.
> I am using SQL 2K.
> Thanks,
> J Smith
>
|||Free Backup Software from Darren Green is available at www.sqldts.com
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jessy Martin" <Jessy_Smith79@.hotmail.com> wrote in message
news:uMDTg4gZFHA.3048@.TK2MSFTNGP14.phx.gbl...
>I know If I store the DTS packages in SQL Server it will be stored in the
> msdb database.
> Also all the job scheduling information is stored in the msdb database.
> Even though I am taking backup of system databases, I would like to know
> if
> is there any way I can export all the DTS packages and jobs in any
> different
> way. This is only an additional extra precaution incase If I am not able
> to
> restore the system database in the event of disaster.
> I am able to open the DTS packages individually and store as .dts file. It
> is a time consuming process.
> I am using SQL 2K.
> Thanks,
> J Smith
>
sql

Backing up DTS and SQL jobs....

I know If I store the DTS packages in SQL Server it will be stored in the
msdb database.
Also all the job scheduling information is stored in the msdb database.
Even though I am taking backup of system databases, I would like to know if
is there any way I can export all the DTS packages and jobs in any different
way. This is only an additional extra precaution incase If I am not able to
restore the system database in the event of disaster.
I am able to open the DTS packages individually and store as .dts file. It
is a time consuming process.
I am using SQL 2K.
Thanks,
J SmithFor DTS backup, I use a neat little program called, "DTS Backup 2000." It's
freeware.
"Jessy Martin" <Jessy_Smith79@.hotmail.com> wrote in message
news:uMDTg4gZFHA.3048@.TK2MSFTNGP14.phx.gbl...
>I know If I store the DTS packages in SQL Server it will be stored in the
> msdb database.
> Also all the job scheduling information is stored in the msdb database.
> Even though I am taking backup of system databases, I would like to know
> if
> is there any way I can export all the DTS packages and jobs in any
> different
> way. This is only an additional extra precaution incase If I am not able
> to
> restore the system database in the event of disaster.
> I am able to open the DTS packages individually and store as .dts file. It
> is a time consuming process.
> I am using SQL 2K.
> Thanks,
> J Smith
>|||Free Backup Software from Darren Green is available at www.sqldts.com
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jessy Martin" <Jessy_Smith79@.hotmail.com> wrote in message
news:uMDTg4gZFHA.3048@.TK2MSFTNGP14.phx.gbl...
>I know If I store the DTS packages in SQL Server it will be stored in the
> msdb database.
> Also all the job scheduling information is stored in the msdb database.
> Even though I am taking backup of system databases, I would like to know
> if
> is there any way I can export all the DTS packages and jobs in any
> different
> way. This is only an additional extra precaution incase If I am not able
> to
> restore the system database in the event of disaster.
> I am able to open the DTS packages individually and store as .dts file. It
> is a time consuming process.
> I am using SQL 2K.
> Thanks,
> J Smith
>

Backing up DTS and SQL jobs....

I know If I store the DTS packages in SQL Server it will be stored in the
msdb database.
Also all the job scheduling information is stored in the msdb database.
Even though I am taking backup of system databases, I would like to know if
is there any way I can export all the DTS packages and jobs in any different
way. This is only an additional extra precaution incase If I am not able to
restore the system database in the event of disaster.
I am able to open the DTS packages individually and store as .dts file. It
is a time consuming process.
I am using SQL 2K.
Thanks,
J SmithFor DTS backup, I use a neat little program called, "DTS Backup 2000." It's
freeware.
"Jessy Martin" <Jessy_Smith79@.hotmail.com> wrote in message
news:uMDTg4gZFHA.3048@.TK2MSFTNGP14.phx.gbl...
>I know If I store the DTS packages in SQL Server it will be stored in the
> msdb database.
> Also all the job scheduling information is stored in the msdb database.
> Even though I am taking backup of system databases, I would like to know
> if
> is there any way I can export all the DTS packages and jobs in any
> different
> way. This is only an additional extra precaution incase If I am not able
> to
> restore the system database in the event of disaster.
> I am able to open the DTS packages individually and store as .dts file. It
> is a time consuming process.
> I am using SQL 2K.
> Thanks,
> J Smith
>|||Free Backup Software from Darren Green is available at www.sqldts.com
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jessy Martin" <Jessy_Smith79@.hotmail.com> wrote in message
news:uMDTg4gZFHA.3048@.TK2MSFTNGP14.phx.gbl...
>I know If I store the DTS packages in SQL Server it will be stored in the
> msdb database.
> Also all the job scheduling information is stored in the msdb database.
> Even though I am taking backup of system databases, I would like to know
> if
> is there any way I can export all the DTS packages and jobs in any
> different
> way. This is only an additional extra precaution incase If I am not able
> to
> restore the system database in the event of disaster.
> I am able to open the DTS packages individually and store as .dts file. It
> is a time consuming process.
> I am using SQL 2K.
> Thanks,
> J Smith
>

Backing up database

Hi All. I currently have a SQL server database which I
back up nightly using a job defined in SQL server and a
USB 2.0 external HD. My question is: I have created a .bat
file to do the backup to the external drive. The file
shuts down all SQL services that are running first, it
backes up the file (both .mdf/.ldf) then it restarts the
server and the servces (sql agent etc). The database is
only about 1/2 GB at this point so it takes about 10
minutes to back the whole \Data directory up. What I'd
like to know is, is there any implications for the
database or server using such a procedure every night 5
nights a week? Or it it completely fine? Thank you for
your help
Leo"Leo" <anonymous@.discussions.microsoft.com> wrote in message
news:03b501c3ae2a$61c166b0$a501280a@.phx.gbl...
> Hi All. I currently have a SQL server database which I
> back up nightly using a job defined in SQL server and a
> USB 2.0 external HD. My question is: I have created a .bat
> file to do the backup to the external drive. The file
> shuts down all SQL services that are running first, it
> backes up the file (both .mdf/.ldf) then it restarts the
> server and the servces (sql agent etc). The database is
> only about 1/2 GB at this point so it takes about 10
> minutes to back the whole \Data directory up. What I'd
> like to know is, is there any implications for the
> database or server using such a procedure every night 5
> nights a week? Or it it completely fine? Thank you for
> your help
>
Well that's not how most people do SQL Server backups.
First off, you only have 1 backup. If you have a problem you don't catch
for a couple of days, or a datafile corruption that prevents SqlServer from
restarting you would be in trouble.
Second, your transaction logs will just keep growing. You have to do a log
file backup to truncate them.
Third, you have to shut down the database.
In Enterprise Manager you can easilly set up a Database Maintence Plan for
the server. This will create SQL Agent jobs to perform database and/or log
backups on a schedule. For each schedule you can set a retention period for
the backup files. So you can set up one schedule to do nightly backups
which are retained for say, 2 weeks, and another to to monthly backups which
are retained for a year.
David|||Leo,
This is kind of offline backup strategy that you are opting for. If your business permits taking
application offline then you can implement this strategy otherwise you can opt for native SQL Server
backup (Inclusive of full /differential/transaction log backups). This can be done while database is
online and no need to shutdown the server. Taking backups through SQL Server native backups will
give you flexibility to restore database to a particular point of time or taking differential
backups etc, which will not be possible if you are taking cold / OS level backup by shutting down
the server. You can see more help on backup and restore commands in Books online.
Refer to following url as well.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_bkprst_63eh.asp
--
- Vishal|||Thank you gentlemen. I should have clarified that I do
daily backups through SQL server of course. I back up all
the databases that way. This *cold* way of backing up is
just an *extra* step I take just in case my whole drive
fails, or something happens that I cannot in no way
restore from the backup tape or the backup folder in SQL.
All I wanted to know was if there would be a problem for
the database shutting down SQL server every night and
doing the cold backup. I have no problem shutting it down
for 15 minutes at night since the production server is
only used from 9-5. Thanks anyway..
Leo
>--Original Message--
>Hi All. I currently have a SQL server database which I
>back up nightly using a job defined in SQL server and a
>USB 2.0 external HD. My question is: I have created
a .bat
>file to do the backup to the external drive. The file
>shuts down all SQL services that are running first, it
>backes up the file (both .mdf/.ldf) then it restarts the
>server and the servces (sql agent etc). The database is
>only about 1/2 GB at this point so it takes about 10
>minutes to back the whole \Data directory up. What I'd
>like to know is, is there any implications for the
>database or server using such a procedure every night 5
>nights a week? Or it it completely fine? Thank you for
>your help
>Leo
>.
>|||This (may) be better than using a bat file, I use it to chuck a copy over to
another server, as a secondary backup to a Backup Job, I just run it in task
scheduler.
'************************************************************************
'VBSCRIP to backup database's and email results
'1 Novenber 2003 Don Grover
'************************************************************************
'Open connection to SQL Server
Set Conn = CreateObject("ADODB.Connection")
Conn.Open _
"Provider=SQLOLEDB" & _
";Data Source=assoftsvr" & _
";Integrated Security=SSPI"
'Call the backup routine
DoBackup "GTS"
DoBackup "CokeShop"
DoBackup "BGINFO"
Conn.Close
Set Conn = Nothing
Sub DoBackup(sDbName)
'Sub accepts a databse name and backs up to predefined location on another
server
On Error Resume Next
Conn.Execute _
"BACKUP DATABASE " & sDbName & _
" TO DISK='\\nassvr\Backups\" & sDbName & "_db_" &
formatdatetime(now,1) & ".bak'" & _
" WITH INIT"
Conn.Execute _
"BACKUP LOG " & sDbName & _
" TO DISK='\\nassvr\Backups\" & sDbName & "_log_" &
formatdatetime(now,1) & ".bak'" & _
" "
If Err.Number = 0 Then
SendEmail sDbName,"SUCCESS"
Else
SendEmail sDbName,"BACKUP FAILED " & Err.Number & "Desc: " &
Err.Description
End If
Err.Clear
On Error Goto 0
End Sub
Sub SendEmail(sDatabaseName,sMessage)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "support@.assoft.com.au"
objEmail.To = "Don Grover <dgrover@.assoft.com.au>"
objEmail.Subject = "Backed up " & sDatabaseName & " on " &
formatdatetime(now,1)
objEmail.Textbody = "Backup " & sMessage & " of " & sDatabaseName & " to
\\NASSvr...."
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"assoftsvr"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Set objEmail = Nothing
End Sub
'Wscript.Echo "Backup complete"sql

Monday, March 19, 2012

back up job not backing up properly?

I had created 7 jobs to back up our database every day, the files were
created, and the modified dates have been updating on the files that
were created, so I never bothered to check the data, as it was only a
temporary solution anyway. However, somebody at work recently deleted a
lot of data, so we went to restore last nights back-up, however the
back-ups apparently weren't working as intended. The data is old, here
is one of my scripts. Does anyone notice anything in there that might
'cause the files not to be updated properly with fresh data?
USE msdb
EXEC sp_add_job @.job_name = 'Tuesday_MagStats_Backup',
@.enabled = 1,
@.description = 'Tuesday_MagStats_Backup',
@.owner_login_name = 'sa',
@.notify_level_eventlog = 2,
@.notify_level_email = 2,
@.notify_level_netsend =2,
@.notify_level_page = 2
-- @.notify_email_operator_name = 'email name'
go
-- Add job step (backup data).
USE msdb
EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
@.step_name = 'Tuesday_MagStats_Backup',
@.subsystem = 'TSQL',
@.command = 'BACKUP DATABASE magstats TO DISK = ''c:\backups\Tuesday_databasebackup.bak''',
@.on_success_action = 3,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add job step (backup log).
USE msdb
EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
@.step_name = 'Tuesday_Magstats_Log_Backup',
@.subsystem = 'TSQL',
@.command = 'BACKUP LOG magstats TO DISK = ''c:\backups\Tuesday_log_databasebackup.log''',
@.on_success_action = 1,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add the target servers.
USE msdb
EXEC sp_add_jobserver @.job_name = 'Tuesday_MagStats_Backup',
@.server_name = N'(local)'
-- Schedule job.
USE msdb
EXEC sp_add_jobschedule @.job_name = 'Tuesday_MagStats_Backup',
@.name = 'ScheduledBackup_MagStats_DB',
@.freq_type = 8, --weekly
@.freq_interval = 4, --Tuesday
@.freq_recurrence_factor = 1, --weekly inbetween
@.active_start_time = '043000' -- (043000 = 4:30 AM) 24hr HHMMSS.
goApparently, this method will keep many back-ups within one file, and
when trying to restore through command line with osql, it restores the
frist one on the file. I was able to restore the correct database using
MS SQL Server Management Studio Express.|||If you don't use the WITH INIT option of the BACKUP command all new backups
are appended to the existing backup device. In order to restore from this
you need to tell SQL Server which backup in the device you need. Please
refer to RESTORE in BOL for more details.
--
Andrew J. Kelly SQL MVP
"KBuser" <sakred@.element9media.com> wrote in message
news:1137002233.526102.65220@.o13g2000cwo.googlegroups.com...
>I had created 7 jobs to back up our database every day, the files were
> created, and the modified dates have been updating on the files that
> were created, so I never bothered to check the data, as it was only a
> temporary solution anyway. However, somebody at work recently deleted a
> lot of data, so we went to restore last nights back-up, however the
> back-ups apparently weren't working as intended. The data is old, here
> is one of my scripts. Does anyone notice anything in there that might
> 'cause the files not to be updated properly with fresh data?
> USE msdb
> EXEC sp_add_job @.job_name = 'Tuesday_MagStats_Backup',
> @.enabled = 1,
> @.description = 'Tuesday_MagStats_Backup',
> @.owner_login_name = 'sa',
> @.notify_level_eventlog = 2,
> @.notify_level_email = 2,
> @.notify_level_netsend =2,
> @.notify_level_page = 2
> -- @.notify_email_operator_name = 'email name'
> go
> -- Add job step (backup data).
> USE msdb
> EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
> @.step_name = 'Tuesday_MagStats_Backup',
> @.subsystem = 'TSQL',
> @.command = 'BACKUP DATABASE magstats TO DISK => ''c:\backups\Tuesday_databasebackup.bak''',
> @.on_success_action = 3,
> @.retry_attempts = 5,
> @.retry_interval = 5
> go
> -- Add job step (backup log).
> USE msdb
> EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
> @.step_name = 'Tuesday_Magstats_Log_Backup',
> @.subsystem = 'TSQL',
> @.command = 'BACKUP LOG magstats TO DISK => ''c:\backups\Tuesday_log_databasebackup.log''',
> @.on_success_action = 1,
> @.retry_attempts = 5,
> @.retry_interval = 5
> go
> -- Add the target servers.
> USE msdb
> EXEC sp_add_jobserver @.job_name = 'Tuesday_MagStats_Backup',
> @.server_name = N'(local)'
> -- Schedule job.
> USE msdb
> EXEC sp_add_jobschedule @.job_name = 'Tuesday_MagStats_Backup',
> @.name = 'ScheduledBackup_MagStats_DB',
> @.freq_type = 8, --weekly
> @.freq_interval = 4, --Tuesday
> @.freq_recurrence_factor = 1, --weekly inbetween
> @.active_start_time = '043000' -- (043000 = 4:30 AM) 24hr HHMMSS.
> go
>

back up job not backing up properly?

I had created 7 jobs to back up our database every day, the files were
created, and the modified dates have been updating on the files that
were created, so I never bothered to check the data, as it was only a
temporary solution anyway. However, somebody at work recently deleted a
lot of data, so we went to restore last nights back-up, however the
back-ups apparently weren't working as intended. The data is old, here
is one of my scripts. Does anyone notice anything in there that might
'cause the files not to be updated properly with fresh data?
USE msdb
EXEC sp_add_job @.job_name = 'Tuesday_MagStats_Backup',
@.enabled = 1,
@.description = 'Tuesday_MagStats_Backup',
@.owner_login_name = 'sa',
@.notify_level_eventlog = 2,
@.notify_level_email = 2,
@.notify_level_netsend =2,
@.notify_level_page = 2
-- @.notify_email_operator_name = 'email name'
go
-- Add job step (backup data).
USE msdb
EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
@.step_name = 'Tuesday_MagStats_Backup',
@.subsystem = 'TSQL',
@.command = 'BACKUP DATABASE magstats TO DISK =
''c:\backups\Tuesday_databasebackup.bak''',
@.on_success_action = 3,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add job step (backup log).
USE msdb
EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
@.step_name = 'Tuesday_Magstats_Log_Backup',
@.subsystem = 'TSQL',
@.command = 'BACKUP LOG magstats TO DISK =
''c:\backups\Tuesday_log_databasebackup.log''',
@.on_success_action = 1,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add the target servers.
USE msdb
EXEC sp_add_jobserver @.job_name = 'Tuesday_MagStats_Backup',
@.server_name = N'(local)'
-- Schedule job.
USE msdb
EXEC sp_add_jobschedule @.job_name = 'Tuesday_MagStats_Backup',
@.name = 'ScheduledBackup_MagStats_DB',
@.freq_type = 8, --weekly
@.freq_interval = 4, --Tuesday
@.freq_recurrence_factor = 1, --weekly inbetween
@.active_start_time = '043000' -- (043000 = 4:30 AM) 24hr HHMMSS.
go
Apparently, this method will keep many back-ups within one file, and
when trying to restore through command line with osql, it restores the
frist one on the file. I was able to restore the correct database using
MS SQL Server Management Studio Express.
|||If you don't use the WITH INIT option of the BACKUP command all new backups
are appended to the existing backup device. In order to restore from this
you need to tell SQL Server which backup in the device you need. Please
refer to RESTORE in BOL for more details.
Andrew J. Kelly SQL MVP
"KBuser" <sakred@.element9media.com> wrote in message
news:1137002233.526102.65220@.o13g2000cwo.googlegro ups.com...
>I had created 7 jobs to back up our database every day, the files were
> created, and the modified dates have been updating on the files that
> were created, so I never bothered to check the data, as it was only a
> temporary solution anyway. However, somebody at work recently deleted a
> lot of data, so we went to restore last nights back-up, however the
> back-ups apparently weren't working as intended. The data is old, here
> is one of my scripts. Does anyone notice anything in there that might
> 'cause the files not to be updated properly with fresh data?
> USE msdb
> EXEC sp_add_job @.job_name = 'Tuesday_MagStats_Backup',
> @.enabled = 1,
> @.description = 'Tuesday_MagStats_Backup',
> @.owner_login_name = 'sa',
> @.notify_level_eventlog = 2,
> @.notify_level_email = 2,
> @.notify_level_netsend =2,
> @.notify_level_page = 2
> -- @.notify_email_operator_name = 'email name'
> go
> -- Add job step (backup data).
> USE msdb
> EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
> @.step_name = 'Tuesday_MagStats_Backup',
> @.subsystem = 'TSQL',
> @.command = 'BACKUP DATABASE magstats TO DISK =
> ''c:\backups\Tuesday_databasebackup.bak''',
> @.on_success_action = 3,
> @.retry_attempts = 5,
> @.retry_interval = 5
> go
> -- Add job step (backup log).
> USE msdb
> EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
> @.step_name = 'Tuesday_Magstats_Log_Backup',
> @.subsystem = 'TSQL',
> @.command = 'BACKUP LOG magstats TO DISK =
> ''c:\backups\Tuesday_log_databasebackup.log''',
> @.on_success_action = 1,
> @.retry_attempts = 5,
> @.retry_interval = 5
> go
> -- Add the target servers.
> USE msdb
> EXEC sp_add_jobserver @.job_name = 'Tuesday_MagStats_Backup',
> @.server_name = N'(local)'
> -- Schedule job.
> USE msdb
> EXEC sp_add_jobschedule @.job_name = 'Tuesday_MagStats_Backup',
> @.name = 'ScheduledBackup_MagStats_DB',
> @.freq_type = 8, --weekly
> @.freq_interval = 4, --Tuesday
> @.freq_recurrence_factor = 1, --weekly inbetween
> @.active_start_time = '043000' -- (043000 = 4:30 AM) 24hr HHMMSS.
> go
>

back up job not backing up properly?

I had created 7 jobs to back up our database every day, the files were
created, and the modified dates have been updating on the files that
were created, so I never bothered to check the data, as it was only a
temporary solution anyway. However, somebody at work recently deleted a
lot of data, so we went to restore last nights back-up, however the
back-ups apparently weren't working as intended. The data is old, here
is one of my scripts. Does anyone notice anything in there that might
'cause the files not to be updated properly with fresh data?
USE msdb
EXEC sp_add_job @.job_name = 'Tuesday_MagStats_Backup',
@.enabled = 1,
@.description = 'Tuesday_MagStats_Backup',
@.owner_login_name = 'sa',
@.notify_level_eventlog = 2,
@.notify_level_email = 2,
@.notify_level_netsend =2,
@.notify_level_page = 2
-- @.notify_email_operator_name = 'email name'
go
-- Add job step (backup data).
USE msdb
EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
@.step_name = 'Tuesday_MagStats_Backup',
@.subsystem = 'TSQL',
@.command = 'BACKUP DATABASE magstats TO DISK =
''c:\backups\Tuesday_databasebackup.bak''',
@.on_success_action = 3,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add job step (backup log).
USE msdb
EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
@.step_name = 'Tuesday_Magstats_Log_Backup',
@.subsystem = 'TSQL',
@.command = 'BACKUP LOG magstats TO DISK =
''c:\backups\Tuesday_log_databasebackup.log''',
@.on_success_action = 1,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add the target servers.
USE msdb
EXEC sp_add_jobserver @.job_name = 'Tuesday_MagStats_Backup',
@.server_name = N'(local)'
-- Schedule job.
USE msdb
EXEC sp_add_jobschedule @.job_name = 'Tuesday_MagStats_Backup',
@.name = 'ScheduledBackup_MagStats_DB',
@.freq_type = 8, --weekly
@.freq_interval = 4, --Tuesday
@.freq_recurrence_factor = 1, --weekly inbetween
@.active_start_time = '043000' -- (043000 = 4:30 AM) 24hr HHMMSS.
goApparently, this method will keep many back-ups within one file, and
when trying to restore through command line with osql, it restores the
frist one on the file. I was able to restore the correct database using
MS SQL Server Management Studio Express.|||If you don't use the WITH INIT option of the BACKUP command all new backups
are appended to the existing backup device. In order to restore from this
you need to tell SQL Server which backup in the device you need. Please
refer to RESTORE in BOL for more details.
Andrew J. Kelly SQL MVP
"KBuser" <sakred@.element9media.com> wrote in message
news:1137002233.526102.65220@.o13g2000cwo.googlegroups.com...
>I had created 7 jobs to back up our database every day, the files were
> created, and the modified dates have been updating on the files that
> were created, so I never bothered to check the data, as it was only a
> temporary solution anyway. However, somebody at work recently deleted a
> lot of data, so we went to restore last nights back-up, however the
> back-ups apparently weren't working as intended. The data is old, here
> is one of my scripts. Does anyone notice anything in there that might
> 'cause the files not to be updated properly with fresh data?
> USE msdb
> EXEC sp_add_job @.job_name = 'Tuesday_MagStats_Backup',
> @.enabled = 1,
> @.description = 'Tuesday_MagStats_Backup',
> @.owner_login_name = 'sa',
> @.notify_level_eventlog = 2,
> @.notify_level_email = 2,
> @.notify_level_netsend =2,
> @.notify_level_page = 2
> -- @.notify_email_operator_name = 'email name'
> go
> -- Add job step (backup data).
> USE msdb
> EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
> @.step_name = 'Tuesday_MagStats_Backup',
> @.subsystem = 'TSQL',
> @.command = 'BACKUP DATABASE magstats TO DISK =
> ''c:\backups\Tuesday_databasebackup.bak''',
> @.on_success_action = 3,
> @.retry_attempts = 5,
> @.retry_interval = 5
> go
> -- Add job step (backup log).
> USE msdb
> EXEC sp_add_jobstep @.job_name = 'Tuesday_MagStats_Backup',
> @.step_name = 'Tuesday_Magstats_Log_Backup',
> @.subsystem = 'TSQL',
> @.command = 'BACKUP LOG magstats TO DISK =
> ''c:\backups\Tuesday_log_databasebackup.log''',
> @.on_success_action = 1,
> @.retry_attempts = 5,
> @.retry_interval = 5
> go
> -- Add the target servers.
> USE msdb
> EXEC sp_add_jobserver @.job_name = 'Tuesday_MagStats_Backup',
> @.server_name = N'(local)'
> -- Schedule job.
> USE msdb
> EXEC sp_add_jobschedule @.job_name = 'Tuesday_MagStats_Backup',
> @.name = 'ScheduledBackup_MagStats_DB',
> @.freq_type = 8, --weekly
> @.freq_interval = 4, --Tuesday
> @.freq_recurrence_factor = 1, --weekly inbetween
> @.active_start_time = '043000' -- (043000 = 4:30 AM) 24hr HHMMSS.
> go
>