Skip to main content
Version: v1.0.67.0

Copy data to and from a DxEnterpriseSqlAg container

This short guide will go through methods of copying data files to and from a SQL Server container of a DxEnterpriseSqlAg deployment.

Using kubectl

With access to the kubectl command for the Kubernetes cluster, the process of copying files in and out of the container is straightforward.

To list files in the SQL Server data folder, for the first pod of a deployment named dxesqlag, run:

kubectl exec -c mssql dxesqlag-0 -- ls -la /var/opt/mssql

To copy the mssql.conf file out of that pod to the local directory, run:

kubectl cp -c mssql dxesqlag-0:/var/opt/mssql/mssql.conf mssql.conf

To copy a local file called data.bak into the pod's data directory, run:

kubectl cp -c mssql data.bak dxesqlag-0:/var/opt/mssql

Additional information:

Using CloudCommander, a browser-based file manager

Another option for access to the file system of the SQL Server container is to use CloudCommander, a browser-based file manager. To do so, we will add an accessory container definition to the DxEnterpriseSqlAg, which is highlighted below:

DxEnterpriseSqlAg.yaml
apiVersion: dh2i.com/v1
kind: DxEnterpriseSqlAg
metadata:
name: dxesqlag
spec:
synchronousReplicas: 3
...
template:
spec:
...
containers:
- name: cloudcmd
image: docker.io/coderaiser/cloudcmd
env:
- name: CLOUDCMD_AUTH
value: 'true'
- name: CLOUDCMD_USERNAME
value: sa
- name: CLOUDCMD_PASSWORD
valueFrom:
secretKeyRef:
name: mssql
key: MSSQL_SA_PASSWORD
- name: CLOUDCMD_ONE_FILE_PANEL
value: 'true'
- name: CLOUDCMD_ROOT
value: /mnt/fs
volumeMounts:
mountPath: /mnt/fs
name: mssql

This configures a CloudCommander accessory container in each pod:

  • With access to the SQL Server data volume
  • As an HTTP (not HTTPS) server, listening on port 8000
  • With authentication required
  • With login credentials 'sa', and the SQL Server SA password

Other configuration options are explained in detail here.

Depending on which connectivity option is being used to access the Kubernetes cluster, it may be necessary to add a new Service definition providing access to CloudCommander on port 8000. This should follow the same methods used to provide application access to SQL Server on port 1433.

Additional information: