Skip to content

Instantly share code, notes, and snippets.

@gazlu
Created December 6, 2016 18:44
Show Gist options
  • Save gazlu/9e5418a6c3dc8b03d7a39d7ea364db87 to your computer and use it in GitHub Desktop.
Save gazlu/9e5418a6c3dc8b03d7a39d7ea364db87 to your computer and use it in GitHub Desktop.
Backup SQL Server localdb database with sqlcmd
sqlcmd -E -S "(localdb)\v11.0" -q "BACKUP DATABASE <DBNAME> TO DISK='<DRIVE>:\<FOLDER_PATH>\<BACKUP_FILE_NAME>.bak'"
@natenho
Copy link

natenho commented Dec 9, 2018

You can use "-Q" instead of "-q" to backup and exit sqlcmd. Useful for using in scheduled tasks!

Good to mention that some instances of localdb are connected via "(localdb)\MSSQLLocalDB" instead of "(localdb)\v11.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment