Difference between revisions of "Sqlcmd"
Jump to navigation
Jump to search
(Created page with "# backup ``` sqlcmd -S 10.x.x.x -U sa -P ${PASS} -d master -Q "BACKUP DATABASE demo TO DISK='C:\Temp\demo.bak' WITH COPY_ONLY" ``` - WITH FORMAT") |
|||
Line 5: | Line 5: | ||
- WITH FORMAT | - WITH FORMAT | ||
+ | |||
+ | |||
+ | # Backup Restore | ||
+ | |||
+ | List DB Logical Names | ||
+ | ``` | ||
+ | RESTORE FILELISTONLY FROM DISK = '/bkp/mydb.bak'; | ||
+ | ``` | ||
+ | |||
+ | Restore in container | ||
+ | ``` | ||
+ | RESTORE DATABASE mydb | ||
+ | FROM DISK = '/bkp/file.bak' | ||
+ | WITH | ||
+ | MOVE 'mydb' TO '/var/opt/mssql/data/mydb.mdf', | ||
+ | MOVE 'mydb_log' TO '/var/opt/mssql/data/mydb.ldf', | ||
+ | REPLACE; -- Use REPLACE if the database already exists | ||
+ | GO | ||
+ | ``` |
Revision as of 04:08, 3 February 2024
backup
sqlcmd -S 10.x.x.x -U sa -P ${PASS} -d master -Q "BACKUP DATABASE demo TO DISK='C:\Temp\demo.bak' WITH COPY_ONLY"
- WITH FORMAT
Backup Restore
List DB Logical Names
RESTORE FILELISTONLY FROM DISK = '/bkp/mydb.bak';
Restore in container
RESTORE DATABASE mydb FROM DISK = '/bkp/file.bak' WITH MOVE 'mydb' TO '/var/opt/mssql/data/mydb.mdf', MOVE 'mydb_log' TO '/var/opt/mssql/data/mydb.ldf', REPLACE; -- Use REPLACE if the database already exists GO