Showing posts with label schedule. Show all posts
Showing posts with label schedule. Show all posts

Saturday, February 25, 2012

backups

I am in search of a simple .bat file or .vbs script that I can use to
stop my SQL database server. I am looking to schedule a script of sorts
to initiate at a certain time every day. This script needs to be able to
stop my server and/or initiate a backup. The script should be able to be
ran remotely from the lan. can anyone help me?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!"jeff wilmoth" <jeff_wilmoth@.yahoo.com> wrote in message
news:40185174$0$70300$75868355@.news.frii.net...
> I am in search of a simple .bat file or .vbs script that I can use to
> stop my SQL database server. I am looking to schedule a script of sorts
> to initiate at a certain time every day. This script needs to be able to
> stop my server and/or initiate a backup. The script should be able to be
> ran remotely from the lan. can anyone help me?

First question, why not use the online backup capabilities of SQL Server?

In any case, a simple

NET STOP MSSQLSERVER

and

NET START MSSQLSERVER

will stop and start SQL Server

If you have SQL Server Agent running, you can either do:

NET STOP SQLSERVERAGENT
NET STOP MSSQLSERVER

or

NET STOP MSSQLSERVER /Y

And then to start either

NET START MSSQLSERVER
NET START SQLSERVERAGENT

or simply

NET START SQLSERVERAGENT

which should start SQL Server first.

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Backups

I have created a backup schedule for all databases on a
SQL server. I have Created a Backup device for each db.
and a single stored procedure that is called with database
name, device & retain days passed as parameters. All
Devices are network locations. I didn't want these backups
to swallow the entire disk space so i set the retain days
to 14. After 2 weeks i hoped that each backup would have
been overwriten. Well that was my logic. 2 weeks are up
and the files created are still growing. After some
investigation it is apparent that the expiry dates have
been passed but the backups sets have not been
overwritten. So much for my plan. I have now re-read BOL
and realised that i have got my wires crossed, the entire
media is overwriten when the expiry dates of all backups
within have been reached. To me this is topsy turvy, why
would i wish to overwrite an entire backup file, maybe if
i had taken a back up of the backup then i would wish to
delete it. Have i yet again misunderstood BOL. What i want
to do is maintain a dynamic history of backups. I back up
my database to a device, this backup lasts for 2 weeks and
then is overwriten. so the actual physical file is never
deleted, only the contents within when the expiry date is
reached.
Help!!!!!!!Expiredays and retaindays are only there to not allow you to overwrite using
the INIT before a certain day. If you aren't using INIT or if you are using
NOINIT, it will always be append. And, it is all or nothing.
If you want generation handling, either use the Maint Wizard, a 3:rd party
like www.dbmaint.com or some TSQL programming to handle this (using more
than one backup device).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"mat" <anonymous@.discussions.microsoft.com> wrote in message
news:a5ce01c40a8e$5c4c13e0$a601280a@.phx.gbl...
> I have created a backup schedule for all databases on a
> SQL server. I have Created a Backup device for each db.
> and a single stored procedure that is called with database
> name, device & retain days passed as parameters. All
> Devices are network locations. I didn't want these backups
> to swallow the entire disk space so i set the retain days
> to 14. After 2 weeks i hoped that each backup would have
> been overwriten. Well that was my logic. 2 weeks are up
> and the files created are still growing. After some
> investigation it is apparent that the expiry dates have
> been passed but the backups sets have not been
> overwritten. So much for my plan. I have now re-read BOL
> and realised that i have got my wires crossed, the entire
> media is overwriten when the expiry dates of all backups
> within have been reached. To me this is topsy turvy, why
> would i wish to overwrite an entire backup file, maybe if
> i had taken a back up of the backup then i would wish to
> delete it. Have i yet again misunderstood BOL. What i want
> to do is maintain a dynamic history of backups. I back up
> my database to a device, this backup lasts for 2 weeks and
> then is overwriten. so the actual physical file is never
> deleted, only the contents within when the expiry date is
> reached.
> Help!!!!!!!
>|||Thanks Tibor
Are there any sys SP's or XP's that can be used to edit
backup files? Maybe i could remove expired files..
I have created a stored procedure that looks at a backup
device and tells me which full, DIff and TL backups need
to be applied to restore to a specified point in time. It
looks as if this will nor work if i have to create new
devices..rats...
I pull my hair out some times with the illogical-ness of
SQL server

>--Original Message--
>Expiredays and retaindays are only there to not allow you
to overwrite using
>the INIT before a certain day. If you aren't using INIT
or if you are using
>NOINIT, it will always be append. And, it is all or
nothing.
>If you want generation handling, either use the Maint
Wizard, a 3:rd party
>like www.dbmaint.com or some TSQL programming to handle
this (using more
>than one backup device).
>--
>Tibor Karaszi, SQL Server MVP
>http://www.karaszi.com/sqlserver/default.asp
>
>"mat" <anonymous@.discussions.microsoft.com> wrote in
message
>news:a5ce01c40a8e$5c4c13e0$a601280a@.phx.gbl...
database
backups
days
entire
why
if
want
up
and
is
>
>.
>|||There are no tool with which you can remove selective backups inside a
backup file, I'm afraid.
One alternative is to do append, say over one day (assume db backup once per
day and log backup once per hour). Then after one day, you rename the Active
to give it a timestamp (so you have generations) and then do INIT to the
active one. This is how we did it in Db Maint up until the current version,
where we decided to not do append anymore.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"mat" <anonymous@.discussions.microsoft.com> wrote in message
news:d7ca01c40a92$7eb09060$a101280a@.phx.gbl...
> Thanks Tibor
> Are there any sys SP's or XP's that can be used to edit
> backup files? Maybe i could remove expired files..
> I have created a stored procedure that looks at a backup
> device and tells me which full, DIff and TL backups need
> to be applied to restore to a specified point in time. It
> looks as if this will nor work if i have to create new
> devices..rats...
> I pull my hair out some times with the illogical-ness of
> SQL server
>
> to overwrite using
> or if you are using
> nothing.
> Wizard, a 3:rd party
> this (using more
> message
> database
> backups
> days
> entire
> why
> if
> want
> up
> and
> is|||Thanks tibor, thats great. Part of my backup script now
contains code to create a backup device every time it is
run that is named depending on a variable passed.
Alternating every week the physical file names change and
the retain days are set to 7. So as you advised i create a
file and add my backups. After a week i swich to a second
file and use this for a week. After another 7 days i
switch back to the original file that is now ready tbe
overwriten.
My SP that advises me of what backup files to aply now
works in pretty much the same way. It creates a device
based on the parameters and returns the backup history. it
then re-creates the device with the second file name and
apends this to the first run.
Thanks so much, you have been a great help..

>--Original Message--
>There are no tool with which you can remove selective
backups inside a
>backup file, I'm afraid.
>One alternative is to do append, say over one day (assume
db backup once per
>day and log backup once per hour). Then after one day,
you rename the Active
>to give it a timestamp (so you have generations) and then
do INIT to the
>active one. This is how we did it in Db Maint up until
the current version,
>where we decided to not do append anymore.
>--
>Tibor Karaszi, SQL Server MVP
>http://www.karaszi.com/sqlserver/default.asp
>
>"mat" <anonymous@.discussions.microsoft.com> wrote in
message
>news:d7ca01c40a92$7eb09060$a101280a@.phx.gbl...
It
you
on a
db.
have
are up
have
BOL
backups
maybe
wish to
back
weeks
never
date
>
>.
>|||I'm glad I could help, mat. Just one thing: As far as I can see, retains
days doesn't really buy you anything. I only mention this so you don't read
anything into this parameter which isn't there... :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"mat" <anonymous@.discussions.microsoft.com> wrote in message
news:d55d01c40aad$fb535920$a501280a@.phx.gbl...
> Thanks tibor, thats great. Part of my backup script now
> contains code to create a backup device every time it is
> run that is named depending on a variable passed.
> Alternating every week the physical file names change and
> the retain days are set to 7. So as you advised i create a
> file and add my backups. After a week i swich to a second
> file and use this for a week. After another 7 days i
> switch back to the original file that is now ready tbe
> overwriten.
> My SP that advises me of what backup files to aply now
> works in pretty much the same way. It creates a device
> based on the parameters and returns the backup history. it
> then re-creates the device with the second file name and
> apends this to the first run.
> Thanks so much, you have been a great help..
>
> backups inside a
> db backup once per
> you rename the Active
> do INIT to the
> the current version,
> message
> It
> you
> on a
> db.
> have
> are up
> have
> BOL
> backups
> maybe
> wish to
> back
> weeks
> never
> date

Friday, February 10, 2012

Backup to Flash Drive

I have a utility I wrote which can backup/restore my database as well
as schedule backups. This has always worked pretty well except when I
try to backup to a USB Flash Disk. When I use one of these the backup
fails. If I backup to the C:/ drive then copy it over to the disk it
works fine but when SQL Server tries to do it, it can't.
I am simply doing the following:

BACKUP DATABASE MyDatabase TO DISK = 'E:/backup.dat_bak' WITH INIT

Anyone know what could be going wrong?"Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message
news:d8653140.0309032311.36f02596@.posting.google.c om...
> I have a utility I wrote which can backup/restore my database as well
> as schedule backups. This has always worked pretty well except when I
> try to backup to a USB Flash Disk. When I use one of these the backup
> fails. If I backup to the C:/ drive then copy it over to the disk it
> works fine but when SQL Server tries to do it, it can't.
> I am simply doing the following:
> BACKUP DATABASE MyDatabase TO DISK = 'E:/backup.dat_bak' WITH INIT
> Anyone know what could be going wrong?

Have LocalSystem account (or account for SQL Server) privileges to access
flash disk?|||bostonpartykid@.yahoo.com (Ray Lavelle) wrote in message news:<d8653140.0309032311.36f02596@.posting.google.com>...
> I have a utility I wrote which can backup/restore my database as well
> as schedule backups. This has always worked pretty well except when I
> try to backup to a USB Flash Disk. When I use one of these the backup
> fails. If I backup to the C:/ drive then copy it over to the disk it
> works fine but when SQL Server tries to do it, it can't.
> I am simply doing the following:
> BACKUP DATABASE MyDatabase TO DISK = 'E:/backup.dat_bak' WITH INIT
> Anyone know what could be going wrong?

You might be seeing this issue:

http://support.microsoft.com/defaul...kb;en-us;281345

Otherwise, can you clarify what you mean by the backup "fails"? Is
there an error message? Presumably the USB drive appears in Windows as
a local drive? And what result do you get if you execute this query:

exec master..xp_cmdshell 'dir e:\'

Simon|||It turned out that the problem was that backing up to a USB disk is a
lot slower so the command timed out. Simply increasing the
commandTimeout solved the problem.

sql@.hayes.ch (Simon Hayes) wrote in message news:<60cd0137.0309040634.7b13ab50@.posting.google.com>...
> bostonpartykid@.yahoo.com (Ray Lavelle) wrote in message news:<d8653140.0309032311.36f02596@.posting.google.com>...
> > I have a utility I wrote which can backup/restore my database as well
> > as schedule backups. This has always worked pretty well except when I
> > try to backup to a USB Flash Disk. When I use one of these the backup
> > fails. If I backup to the C:/ drive then copy it over to the disk it
> > works fine but when SQL Server tries to do it, it can't.
> > I am simply doing the following:
> > BACKUP DATABASE MyDatabase TO DISK = 'E:/backup.dat_bak' WITH INIT
> > Anyone know what could be going wrong?
> You might be seeing this issue:
> http://support.microsoft.com/defaul...kb;en-us;281345
> Otherwise, can you clarify what you mean by the backup "fails"? Is
> there an error message? Presumably the USB drive appears in Windows as
> a local drive? And what result do you get if you execute this query:
> exec master..xp_cmdshell 'dir e:\'
> Simon