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

后端 未结 11 922
北海茫月
北海茫月 2020-11-28 19:35

I\'ve been too lax with performing DB backups on our internal servers.

Is there a simple command line program that I can use to backup certain databases in SQL Serv

11条回答
  •  不知归路
    2020-11-28 19:49

    I found this on a Microsoft Support page http://support.microsoft.com/kb/2019698.

    It works great! And since it came from Microsoft, I feel like it's pretty legit.

    Basically there are two steps.

    1. Create a stored procedure in your master db. See msft link or if it's broken try here: http://pastebin.com/svRLkqnq
    2. Schedule the backup from your task scheduler. You might want to put into a .bat or .cmd file first and then schedule that file.

      sqlcmd -S YOUR_SERVER_NAME\SQLEXPRESS -E -Q "EXEC sp_BackupDatabases @backupLocation='C:\SQL_Backup\', @backupType='F'"  1>c:\SQL_Backup\backup.log            
      

    Obviously replace YOUR_SERVER_NAME with your computer name or optionally try .\SQLEXPRESS and make sure the backup folder exists. In this case it's trying to put it into c:\SQL_Backup

提交回复
热议问题