Showing posts with label written. Show all posts
Showing posts with label written. Show all posts

Friday, March 23, 2012

Scheduling a backup

Hi,

I want to schedule a backup of three databases on a daily basis.

I've written the code to run the 3 backups in TSQL and was wondering how
best to automate this procedure?

Should I put the code in an sproc and then schedule running that command
in the DTS or should I just add the TSQL into a DTS command?? Or is
there a better way of doing this?

I then prefer to use DTSRUNUI to generate the syntax and then schedule
this from the windows scheduler as opposed to the SQL SCheduler in EM
(is this the best way?)

Help would be appreciated

M3ckon

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!"m3ckon" <anonymous@.devdex.com> wrote in message
news:40cdbb60$0$25520$c397aba@.news.newsgroups.ws.. .
> Hi,
> I want to schedule a backup of three databases on a daily basis.
> I've written the code to run the 3 backups in TSQL and was wondering how
> best to automate this procedure?
> Should I put the code in an sproc and then schedule running that command
> in the DTS or should I just add the TSQL into a DTS command?? Or is
> there a better way of doing this?
> I then prefer to use DTSRUNUI to generate the syntax and then schedule
> this from the windows scheduler as opposed to the SQL SCheduler in EM
> (is this the best way?)
> Help would be appreciated
> M3ckon
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!

Putting the code in a procedure may be best, because it's simpler to manage,
and you don't get awkward problems working with EM or other tools which
allow only a very limited area for viewing code. If you're executing a DTS
package, then your geenral approach above seems OK, although the Windows
scheduler is rather limited compared to the MSSQL one, so unless there is a
very good reason not to, I would use the MSSQL scheduler.

Having said all that, using DTS as a backup mechanism is a little unusual,
unless your backups are part of a larger workflow. For simple backups,
maintenance plans are a convenient solution, although since they have some
limitations, you might have to write your own TSQL code sooner or later. But
scheduling a stored procedure in MSSQL is generally less complicated than
scheduling a DTS package, unless you need some extra functionality.

Simon|||Hi

You can do it in serveral ways, but I would control it through a SQL Agent
job. If you run the backup

See sp_add_job, sp_add_jobschedule, and sp_add_jobstep
http://msdn.microsoft.com/library/d...asp?frame=true

If you want see a backup job programmed there is a schedule option at the
bottom of the backup wizard screen in Enterprise Manager.

John

"m3ckon" <anonymous@.devdex.com> wrote in message
news:40cdbb60$0$25520$c397aba@.news.newsgroups.ws.. .
> Hi,
> I want to schedule a backup of three databases on a daily basis.
> I've written the code to run the 3 backups in TSQL and was wondering how
> best to automate this procedure?
> Should I put the code in an sproc and then schedule running that command
> in the DTS or should I just add the TSQL into a DTS command?? Or is
> there a better way of doing this?
> I then prefer to use DTSRUNUI to generate the syntax and then schedule
> this from the windows scheduler as opposed to the SQL SCheduler in EM
> (is this the best way?)
> Help would be appreciated
> M3ckon
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!

Friday, March 9, 2012

Scheduled Backup for SQL Server Express

Not sure if this is the right forum, so please correct me if I'm in error.
I've written a Timeclock application in VB6 for our small chain of retail
stores and storing the data in a SQL Server Express database. All is
working well, but I want to perform a nighly backup of the database and
there appears to be no Maintenance Plan setup wizard in SQL Server Express.
Can anyone provide me with a query that I can launch at a scheduled time to
perform this or another alternative.
Thank you,
BarryThere is no SQL Server Agent in Express edition of SQL Server 2005, so no
scheduled tasks can be performed using standard tools. You may use OS
scheduler and SQLCMD to do this job or write your own backup app. Or, if
your Express instances can be accessed as linked servers from Standard or
Enterprise instance, you may do so by scheduling remote procedure calls on
this instance.
WBR, Evergray
--
Words mean nothing...
"BCS" <bswedeen@.tayloroil.com> wrote in message
news:NgmJf.21119$no3.16791@.tornado.southeast.rr.com...
> Not sure if this is the right forum, so please correct me if I'm in error.
> I've written a Timeclock application in VB6 for our small chain of retail
> stores and storing the data in a SQL Server Express database. All is
> working well, but I want to perform a nighly backup of the database and
> there appears to be no Maintenance Plan setup wizard in SQL Server
> Express.
> Can anyone provide me with a query that I can launch at a scheduled time
> to
> perform this or another alternative.
> Thank you,
> Barry
>|||The command to do a backup is BACKUP and you can see all the details in
BooksOnLine. But which options you use and the exact syntax depends on
exactly what you want to do and how. You might want to have a look at BOL
under BACKUP to get an idea what you want first to see what is available.
Andrew J. Kelly SQL MVP
"BCS" <bswedeen@.tayloroil.com> wrote in message
news:NgmJf.21119$no3.16791@.tornado.southeast.rr.com...
> Not sure if this is the right forum, so please correct me if I'm in error.
> I've written a Timeclock application in VB6 for our small chain of retail
> stores and storing the data in a SQL Server Express database. All is
> working well, but I want to perform a nighly backup of the database and
> there appears to be no Maintenance Plan setup wizard in SQL Server
> Express.
> Can anyone provide me with a query that I can launch at a scheduled time
> to
> perform this or another alternative.
> Thank you,
> Barry
>|||You could use a combination of SQL statements and Scheduled Tasks:
CREATE PROCEDURE nightlybackup
AS
BACKUP DATABASE [yourdb]
TO DISK = 'c:\backups\dbbackup.dat'
BACKUP LOG [yourdb]
TO DISK = 'c:\backups\dblogbackup.dat'
Now create a cmd script; run the below at a command prompt (all on one line,
of course):
echo osql -d [yourdb] -E -Q "EXEC
dbo.nightlybackup">>c:\backups\nightlybackup.cmd
Now add it as a scheduled task (all on one line again):
schtasks /create /tn nightlybackup /tr c:\backups\nightlybackup.cmd /sc
daily /st 00:05:00
This will do a daily backup at 5 minutes after midnight. Do all of this
logged on as a local administrator.
"BCS" wrote:

> Not sure if this is the right forum, so please correct me if I'm in error.
> I've written a Timeclock application in VB6 for our small chain of retail
> stores and storing the data in a SQL Server Express database. All is
> working well, but I want to perform a nighly backup of the database and
> there appears to be no Maintenance Plan setup wizard in SQL Server Express
.
> Can anyone provide me with a query that I can launch at a scheduled time t
o
> perform this or another alternative.
> Thank you,
> Barry
>
>|||Thanks to everyone for your input.
Barry
"Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
news:BD7B78CE-DB95-4E1D-89FC-41F689E94725@.microsoft.com...
> You could use a combination of SQL statements and Scheduled Tasks:
> CREATE PROCEDURE nightlybackup
> AS
> BACKUP DATABASE [yourdb]
> TO DISK = 'c:\backups\dbbackup.dat'
> BACKUP LOG [yourdb]
> TO DISK = 'c:\backups\dblogbackup.dat'
> Now create a cmd script; run the below at a command prompt (all on one
line,
> of course):
> echo osql -d [yourdb] -E -Q "EXEC
> dbo.nightlybackup">>c:\backups\nightlybackup.cmd
> Now add it as a scheduled task (all on one line again):
> schtasks /create /tn nightlybackup /tr c:\backups\nightlybackup.cmd /sc
> daily /st 00:05:00
> This will do a daily backup at 5 minutes after midnight. Do all of this
> logged on as a local administrator.
> --
> "BCS" wrote:
>
error.
retail
Express.
to