Quick method to backup SQL Server database to workstation

On the last project I was working on I did not have physical access to the SQL Server disks in order to get a copy of the backup file created using the SSMS software. I needed to make a copy to my local SQL Server in order to do some testing before I blew away all the data on the “real” SQL Server. SSMS does not appear to have a method to allow you to specify a network path, but T-SQL has that capability with the BACKUP command.

If you complete the following steps you can get a backup copy of the database on your local workstation (assuming you have SQL Server installed locally):

  1. Get the IP address of your local computer using the ipconfig command or some other method.
  2. Make sure you have created a share on your computer in the location where you want the backup file to be stored. For this example I am going to assume there is a share called BACKUP that points to C:BACKUP (again, this share is on your local workstation, not the remote SQL Server)
  3. Connect to the remote database with SSMS
  4. Open a Query Window
  5. Execute the following command (replace 1.1.1.1 with the IP address determined from step 1 and replace YourDatabase with the name of the database you want to backup)

BACKUP DATABASE YourDatabase
TO DISK = '1.1.1.1BackupYourDatabase.bak'
WITH FORMAT,
NAME = 'Full Backup of YourDatabase'

Now you can use SSMS to restore the database to your local copy of SQL Server or just keep it around in case you mess up the production database.

Another useful thing you can do is to schedule this and use the OSQL command line tool to execute the script as part of a development release or any other process. There are lots of options.