What is a simple command line program or script to backup SQL server databases?

I've been also lax with executing DB back-ups on our inner web servers.

Exists a straightforward command line program that I can make use of to backup particular data sources in SQL Server 2005? Or exists a straightforward VBScript?

104
2022-07-14 02:21:44
Source Share
Answers: 3

Schedule the complying with to backup all Databases:

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)

There are additionally even more information on my blog site: just how to Automate SQL Server Express Backups.

10
2022-07-14 04:27:48
Source

If you can locate the DB documents "cp DBFiles backup/"

Almost without a doubt not suggested most of the times , yet it is straightforward as all getup.

1
2022-07-14 04:23:57
Source

To backup a solitary data source from the command line, usage osql or sqlcmd.

"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\osql.exe" 
    -E -Q "BACKUP DATABASE mydatabase TO DISK='C:\tmp\db.bak' WITH FORMAT"

You'll additionally intend to read the documents on BACKUP and also RESTORE and also general procedures.

117
2022-07-14 04:22:50
Source