Migrating SQL Server Databases to Containers On Pure Storage
Introduction
In this bog I will demonstrate how we can migrate an existing SQL Server database running on either a Bare Metal or Virtualised environment to a container platform running on Pure Storage and the Pure Storage Plugin.
Overview of Environment
Source environment
- Virtual machine on ESX 7
- Windows 2016
- SQL Server 2016
- SSMS 18.4
- Database - Demo
Target Environment
Step 1 - Backup Source DB
I am using SSMS UI to backup the database for this example, you can just as easily backup the
database using T-SQL.
Lets Select some data in the table before we backup, so we can compare it to after we migrate to the container
- Backup up the Database
Step 2 - Copy DB backup
Once we have completed the database backup we need to copy it over the docker host, I'm not covering the copy process in this blog, however if you have any questions please feel free to contact me at cbannayan@purestorage.com
Step 3 - Create a new SQL Server Container
- Let's create the container using the persistent volume
- Container name: sqldemo
- volume: sqldemo
- port: 1427
- SQL Server: 2019
- let's log onto the container and confirm our volume is mounted
As we can see, the volume is mounted on /var/opt/mssql with the same serial number "484e" as the volume listing on the array
- Let's log into the container and confirm it's up and running, as you can see we have only the default databases
Step 4 - Copy the backup to the container and restore
- Lets log into the container and restore the database
RESTORE DATABASE demo FROM DISK = N'/var/opt/mssql/backup/demo.bak' \
WITH RECOVERY, MOVE 'demo' TO N'/var/opt/mssql/data/demo.mdf', MOVE \
'demo_log' TO N'/var/opt/mssql/backup/demo_log.ldf'
from the table output we can confirm out data matches the table in source database, lets do
a row count to double check
Source Database:
Step 5 - Now lets Clone the Container
So now that we have migrated the database to the container, this container can now become our GOLD image, from here we can create copies/clones for developers and testers. Using the Pure Storage plugin we will now create a clone of the production container.
You can see from the above output that we have create a new clone volume called sqldemo-clone which has it's source as sqldemo
- Lets log into the new container and confirm our production database exists, notice we have used he new port number 1425 which we used to create the new clone container
Summary
In this blog we have seen how we can migrate an existing production or Source SQL Server Database to a container, whilst production configurations may vary and some may not be fit for containerisation, the ones that are can be done quite easily as shown. Using the Pure Storage Container plugin we have demonstrated how quickly and easily we can clone and create multiple copies of the source database.
More and More organisations are adopting or planning a Container/Kubernetes strategy, Using Pure Storage provides the foundation for the strategy.
Note: Please see my other blogs on configuring SQL Server with containers.
http://bannaych.blogspot.com/2020/04/mssql-server-on-docker-with-pure.html
http://bannaych.blogspot.com/2020/05/cloning-sql-server-containers-with-pure.html
Comments