[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

Backup SQL2008 with a script from task scheduller

Hello,
Title says pretty much what I need - a script to run from windows task scheduller to backup a database.
0
Vaidas911
Asked:
Vaidas911
  • 2
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
0
 
Vaidas911Author Commented:
I like simple script as this:
Use Master
 
Declare @ToExecute VarChar(8000)
 
Select @ToExecute = Coalesce(@ToExecute + 'Backup Database ' + [Name] + ' To Disk =     ''D:\Backups\Databases\' + [Name]   + '.bak'' With Format;' + char(13),'')
From
Master..Sysdatabases
Where
[Name] Not In ('tempdb')
and databasepropertyex ([Name],'Status') = 'online'
 
Execute(@ToExecute)

My queston - is it possible to add parameters to rotate backups, ar should I use anoter script?
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
the above will create a Full backup, you must create some  differential backups and the log backups too also thats just a  sql command, you need either OSQL or sqlCmd to execute a sql command from command prompt , if you check the link i provided, you can handle this easily using the sqlcmd utitlity ..
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now