DATOMILAB

Free tool

SQL Server backup script generator

Generate a ready-to-run SQL Server backup script, batch file, Task Scheduler command and cleanup script. Free, runs in your browser, nothing is uploaded.

Free, no signup Runs in your browser. Nothing is uploaded. By the DatomiLab team

Fill in your server details and get four ready-to-use files: the T-SQL backup script, a batch file that runs it with logging, a cleanup script for old backups, and the Task Scheduler command. Everything is generated in your browser.

Save as D:\SQLBackups\scripts\backup.sql

How to use the files

  1. Create the folders scripts and logs inside your backup folder, and give the SQL Server service account write access to the backup folder. See error 3201 if you are unsure which account that is.
  2. Save each tab's content with the file name shown above it.
  3. Run run_backup.bat once by hand. Check the log and the backup folder.
  4. Run the Task Scheduler command in an administrator command prompt, then right-click the new task and choose Run to test it under the scheduled account.

What the script does

It loops over the selected databases and writes one time-stamped file per database, so backups never overwrite each other. Log backups skip databases in SIMPLE recovery, which cannot have log backups. The batch file records success or failure in a log, and deletes old backups only after a successful run, so a string of failures never removes your last good copy.

What it does not do

  • Copy backups off the server. Add an off-site step with Google Drive or FTP/FTPS.
  • Alert anyone on failure. Someone has to read the log, or you add email.
  • Retry. A temporary failure means no backup until the next run.

The full walk-through is in how to schedule SQL Server Express backups.

Rather not maintain scripts?

Velocity runs scheduled SQL Server and folder backups through a Windows service, sends them to a local folder, FTP/FTPS or Google Drive, retries failures automatically and can email you after each run.