-1

I want to do a full weekly backup of my SQL Server 2012 Express database.

I have created a SQL script and batch file to automatically do a full backup of my database each week and overwrite the existing backup file each time this script is executed.

I am wondering if my syntax is correct and is doing what I intend it to do.

BACKUP DATABASE test TO  
DISK = N'\\path\to\backup\folder\TestBackup.bak' 
WITH NOFORMAT
    , INIT  
    , NAME = N'test Backup'
    , SKIP
    , NOREWIND
    , NOUNLOAD
    , STATS = 10;

Is there anything incorrect in the above backup statement?

closed as off-topic by Colin 't Hart, RolandoMySQLDBA, Paul White, Shanky, Kin Shah Mar 17 '15 at 13:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Colin 't Hart, RolandoMySQLDBA, Paul White, Shanky, Kin Shah
If this question can be reworded to fit the rules in the help center, please edit the question.

  • NOREWIND, NOUNLOAD are superfluous in your case. since they are tape drive-specific options that will have no effect when performing the backup to disk. NOFORMAT simply indicates not to overwrite the header in the backup file - this is the default behavior, and is unnecessary when combined with the INIT option which overwrites all backups in the backup file. You may want to look at the SQL Server Books Online topic about the BACKUP command at msdn.microsoft.com/en-us/library/ms186865.aspx – Max Vernon Mar 17 '15 at 13:30
1

Yes that is correct.

It will backup your database to \\path\to\backup\folder\TestBackup.bak.

INIT will overwrite the file everytime it backups up.

Are you sure you just want one FULL backup ? What about transaction log backups? What if that backup gets corrupted (since you have only one backup and that is being overwritten everytime you take a new full backup) ?

Better append datetime at the end of backup.

I would suggest you to use the script at How to schedule and automate backups of SQL Server databases in SQL Server Express ?

Not the answer you're looking for? Browse other questions tagged or ask your own question.