Difference between revisions of "Database backup and restore"

From Dragon Age Toolset Wiki
Jump to: navigation, search
(Formatting this to make it more readable)
Line 1: Line 1:
The following command-line command will back up the database to a file on disk, assuming you're using the default database name (bw_dragonage_content):
+
The following command-line commands can be used to backup and restore your database, assuming you're using the default database name (bw_dragonage_content):
  
<tt>sqlcmd -S .\BWDATOOLSET -E -Q "BACKUP DATABASE bw_dragonage_content TO DISK = 'C:\Users\Storey\DA Install\data\bw_dragonage_content.bak'"</tt>
 
  
And the following command will restore a database backup:
+
== Backup ==
 +
 
 +
<tt>sqlcmd -S .\BWDATOOLSET -E -Q "BACKUP DATABASE <Database Name> TO DISK = '<Backup Directory><Backup Filename>'"</tt>
 +
 
 +
Where:
 +
 
 +
*''<Database Name>'' is the name of your database, typically bw_dragonage_content
 +
 
 +
*''<Backup Directory>'' is the name of the directory where you want to save the backup file (directory must exist, this process will not create it)
 +
 
 +
*''<Backup Filename>'' is what you are naming the backup file
 +
 
 +
an example:
 +
 
 +
<tt>sqlcmd -S .\BWDATOOLSET -E -Q "BACKUP DATABASE bw_dragonage_content TO DISK = 'C:\Backup\bw_dragonage_content.bak'"</tt>
 +
 
 +
 
 +
== Restore ==
 +
 
 +
<tt>sqlcmd -S .\BWDATOOLSET -E -Q "RESTORE DATABASE <Database Name> FROM DISK = '<Backup Directory><Backup Filename>' WITH REPLACE"</tt>
 +
 
 +
where:
 +
 
 +
*''<Database Name>'' is the name of your database, typically bw_dragonage_content
 +
 
 +
*''<Backup Directory>'' is the name of the directory where the backup file resides
 +
 
 +
*''<Backup Filename>'' is the name of backup file you wish to restore
 +
 
 +
an example:
 +
 
 +
<tt>sqlcmd -S .\BWDATOOLSET -E -Q "RESTORE DATABASE bw_dragonage_content FROM DISK = 'C:\Backup\bw_dragonage_content.bak' WITH REPLACE"</tt>
  
<tt>sqlcmd -S .\BWDATOOLSET -E -Q "RESTORE DATABASE bw_dragonage_content FROM DISK = 'C:\Users\Storey\DA Install\data\bw_dragonage_content.bak' WITH REPLACE"</tt>
 
  
 
If you're restoring to a data store that's in a location other than the store you made the backup from (for example if you're moving your data from one computer to another and the toolset is installed in a different location on the destination machine) you can add the following to the restore command to restore to the new location. If you're restoring to the same place you made the backup from you can omit this.
 
If you're restoring to a data store that's in a location other than the store you made the backup from (for example if you're moving your data from one computer to another and the toolset is installed in a different location on the destination machine) you can add the following to the restore command to restore to the new location. If you're restoring to the same place you made the backup from you can omit this.

Revision as of 00:31, 30 July 2009

The following command-line commands can be used to backup and restore your database, assuming you're using the default database name (bw_dragonage_content):


Backup

sqlcmd -S .\BWDATOOLSET -E -Q "BACKUP DATABASE <Database Name> TO DISK = '<Backup Directory><Backup Filename>'"

Where:

  • <Database Name> is the name of your database, typically bw_dragonage_content
  • <Backup Directory> is the name of the directory where you want to save the backup file (directory must exist, this process will not create it)
  • <Backup Filename> is what you are naming the backup file

an example:

sqlcmd -S .\BWDATOOLSET -E -Q "BACKUP DATABASE bw_dragonage_content TO DISK = 'C:\Backup\bw_dragonage_content.bak'"


Restore

sqlcmd -S .\BWDATOOLSET -E -Q "RESTORE DATABASE <Database Name> FROM DISK = '<Backup Directory><Backup Filename>' WITH REPLACE"

where:

  • <Database Name> is the name of your database, typically bw_dragonage_content
  • <Backup Directory> is the name of the directory where the backup file resides
  • <Backup Filename> is the name of backup file you wish to restore

an example:

sqlcmd -S .\BWDATOOLSET -E -Q "RESTORE DATABASE bw_dragonage_content FROM DISK = 'C:\Backup\bw_dragonage_content.bak' WITH REPLACE"


If you're restoring to a data store that's in a location other than the store you made the backup from (for example if you're moving your data from one computer to another and the toolset is installed in a different location on the destination machine) you can add the following to the restore command to restore to the new location. If you're restoring to the same place you made the backup from you can omit this.

WITH MOVE 'bw_da_content_euts_Data' TO 'C:\Program Files\Dragon Age\toolssql\Data\bw_dragonage_content.mdf', MOVE 'bw_da_content_euts_Log' TO 'C:\Program Files\Dragon Age\toolssql\Data\bw_dragonage_content.ldf'