Some instructions on how to restore a database .bak via an interactive OSQL session for MS SQL Server.
Copied, trimmed, and edited from: http://www.experts-exchange.com/Databases/Q_21503049.html
Login to OSQL:
osql -U sa -p -S localhost
1. Get list of file names as embedded in the SQL Server .bak file:
RESTORE FILELISTONLY FROM DISK = 'C:\MSSQL\Data\mydatabasebackup.bak'
2. Restore.
If you are restoring a database back to it's source, then you just need this:
RESTORE DATABASE mydatabase
FROM DISK = 'C:\MSSQL\Data\mydatabasebackup.bak'
If, instead, the database has moved, e.g. copied from a different computer, use the values from step 1's query output to restore files to a different location:
Pay attention to the logical file names:
RESTORE DATABASE mydatabase
FROM DISK = 'C:\MSSQL\Data\mydatabasebackup.bak'
WITH REPLACE
, MOVE 'mydatabase_data' to 'C:\MSSQL\Data\mydatabase.mdf'
, MOVE 'mydatabase_log' to 'C:\MSSQL\Data\mydatabase.ldf'
Backup Syntax:
OSQL -Usa -PmyPasword -n -Q "BACKUP DATABASE msdb TO DISK = 'c:\msdb.dat_bak'"
Tags: restore, backup, .bak, osql