Backup y restore mssql en Linux

Backup y restore mssql en Linux

creación de carpeta para backup

sudo mkdir -p /backups/sql-server

permisos para usuario mssql

sudo chown mssql /backups/sql-server

testeando la conexión

sqlcmd -U sa -Q 'select "test ok"'

creando backup

sqlcmd -U sa -Q 'BACKUP DATABASE dummy TO DISK = "/backups/sql-server/full.bak";'

restore de la base

sqlcmd -U sa -Q 'RESTORE DATABASE dummy FROM DISK = "/backups/sql-server/full.bak" WITH REPLACE;'

creando base nueva desde backup

sqlcmd -U sa -Q 'RESTORE DATABASE dummy FROM DISK = "/backups/sql-server/full.bak" WITH MOVE "dummy" TO "/var/opt/mssql/data/dummy.mdf", MOVE "dummy_log" TO "/var/opt/mssql/data/dummy_log.ldf", RECOVERY, REPLACE'