Summary
This article provides a list of ApexSQL Restore Command Line Interface switches, explains their usage and provides the CLI statement examples
Description
ApexSQL Restore, a SQL Server database restore tool, has a powerful Command Line Interface (CLI) with a variety of switches. It enables SQL Server database restoration with less memory and CPU usage, and restoration scheduling via SQL Server jobs or Windows Scheduler
The ApexSQL Restore CLI is installed along with the GUI. All features available in the ApexSQL Recover GUI are also available in the CLI
The syntax of the ApexSQL Restore CLI command is:
ApexSQLRestore.com /switch:argument
The following switches are available in the ApexSQL Restore CLI:
- /server: – specifies the SQL Server instance used. If omitted, the (local) instance is used. The abbreviated form is /s:
- /login: – used for SQL Server authentication, along with the password switch. The abbreviated form is /u:
- /password: – used for SQL Server authentication, along with the login switch. The abbreviated form is /p:
- /backup: – specifies the backup path and backup sets to restore. For backup files with multiple backup sets, it’s necessary to specify the ID of the backup set that will be restored, after a semicolon (;). The abbreviated form is /b:
- /restorepath: – specifies the path where the MDF and the LDF files of the restored database will be stored. If omitted, the default location will be used: C:ProgramDataApexSQLApexSQLRestoreRestorePath will be used. The abbreviated form is /pat:
- /attach: – attaches the database. The abbreviated form is /a:
- /remove: – detaches the restored database. The abbreviated form is /r:
- /database: – specifies the name of the restored database. The abbreviated form is /d:
- /help: – lists the switches available in the CLI. The abbreviated form is /?
- /argfile: – specifies file path and name for the XML file with the CLI switches that will be used in the CLI statement. The abbreviated form is /af:
- /console_width: – specifies the width of the Command Prompt window. The abbreviated form is /cw:
- /out_to: – specifies the path and name for the file where the processing messages will be written. The abbreviated form is /out:
- /test:– tests whether the database can be attached or detached. The abbreviated form is /t
- /verbose – prints all processing messages. The abbreviated form is /v
To restore a SQL Server database using the ApexSQL Restore CLI:
- Run the Command Prompt
- Navigate to the folder where ApexSQL Restore is installed:
cd C:\Program Files (x86)\ApexSQL\ApexSQLRestore2012 - Run an ApexSQL Restore CLI command, such as:
ApexSQLRestore.com /s:FujitsuSQL2012 /d:RestoreTest
/backup:E:TestAdventureWorks2012_Full.bak /attach: /v
Examples
To restore the E:\Test\AdventureWorks2012_Full.bak backup as the database named RestoredAW, and store the MDF and the LDF files in the E:\Restored folder:
ApexSQLRestore.com /s:FujitsuSQL2012 /d:RestoredAW
/backup:E:TestAdventureWorks2012_Full.bak /attach: /pat:E:Restored /v
To remove the restored database RestoredAW:
ApexSQLRestore.com /s:FujitsuSQL2012 /d:RestoredAW/remove: /v
To restore the second backup set from the MyDb.bak backup file stored in E:\ApexSQL\backups
ApexSQLRestore.com /s:FujitsuSQL2012 /d:RestoredAW
/backup:E:ApexSQLbackupsMyDb.bak;2 /attach: /v