Advertisement
kromm77

[DOCKER] [SQL SERVER] Copy db from container to another

Jul 17th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourStrong!Passw0rd>' -Q 'BACKUP DATABASE  [demodb] TO DISK = "/var/opt/mssql/data/demodb_LogBackup.bak" WITH STATS = 10'
  2.  
  3. sudo docker cp "sql1:/var/opt/mssql/data/demodb_LogBackup.bak" "C:\temp\DATABASESQLSERVER1.bak"
  4.  
  5. sudo docker cp  "C:\temp\DATABASESQLSERVER1.bak" "sql2:/var/opt/mssql/data/demodb_LogBackup.bak"
  6.  
  7. sudo docker exec -it sql2 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourNewStrong!Passw0rd>' -Q 'RESTORE DATABASE  [yourdbname] FROM DISK = "/var/opt/mssql/data/demodb_LogBackup.bak"'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement