Home Help Backup of MSSQL Express
Backup of MSSQL Express PDF Print E-mail
Wednesday, 27 April 2011 14:03

To backup Microsoft SQL Express databases following commands in an script can be used (cmd or bat)

 

SET bupath=c:\opusallt_backup\
SET DB1=DynaForms
SET DB2=OANET
SET DB3=OANET00
SET DB4=OANET99
IF EXIST %bupath%%DB1%.BAK del %bupath%%DB1%.BAK
sqlcmd -S .\OPUSALLT -E -Q "backup database %DB1% to disk = '%bupath%%DB1%.BAK'"
IF EXIST %bupath%%DB2%.BAK del %bupath%%DB2%.BAK
sqlcmd -S .\OPUSALLT -E -Q "backup database %DB2% to disk = '%bupath%%DB2%.BAK'"
IF EXIST %bupath%%DB3%.BAK del %bupath%%DB3%.BAK
sqlcmd -S .\OPUSALLT -E -Q "backup database %DB3% to disk = '%bupath%%DB3%.BAK'"
IF EXIST %bupath%%DB4%.BAK del %bupath%%DB4%.BAK
sqlcmd -S .\OPUSALLT -E -Q "backup database %DB4% to disk = '%bupath%%DB4%.BAK'"

SET bupath=c:\SQL_backup\

SET DB1=[DataBase1]

SET DB2=[DataBase2]

SET DB3=[DataBase3]

SET DB4=[DataBase4]

IF EXIST %bupath%%DB1%.BAK del %bupath%%DB1%.BAK

sqlcmd -S .\[Database instance] -E -Q "backup database %DB1% to disk = '%bupath%%DB1%.BAK'"

IF EXIST %bupath%%DB2%.BAK del %bupath%%DB2%.BAK

sqlcmd -S .\[Database instance] -E -Q "backup database %DB2% to disk = '%bupath%%DB2%.BAK'"

IF EXIST %bupath%%DB3%.BAK del %bupath%%DB3%.BAK

sqlcmd -S .\[Database instance] -E -Q "backup database %DB3% to disk = '%bupath%%DB3%.BAK'"

IF EXIST %bupath%%DB4%.BAK del %bupath%%DB4%.BAK

sqlcmd -S .\[Database instance] -E -Q "backup database %DB4% to disk = '%bupath%%DB4%.BAK'"

 

 

[Database instance] is the name of the database service that can be seen in sevices the name is in the pharensisis: SQL (?????)

DataBase1 is the first database in the instance etc.

DataBase2

DataBase3

DataBase4

 

If  the data tere are more or fewer databases lines can be added or deleted as needed.

Then you make an Custom backup policy that will run this script in pre processing pleas note to take the tic out of Do not enable on the preprocessing. If the data bases are large DTMF processing can be used ensure that bak extension is in the í DTMF extensions list.


Last Updated on Wednesday, 27 April 2011 17:00