How to copy files to/from a Solace broker
This looks like a frequently asked question - so I try to list all options to transfer files to/from a Solace broker.
Why do you need to transfer files ? This list are just some of the frequent use cases.
- upload certificates (server cert, CA chains) to the broker
- Download configuration backup files from the broker
- upload script files to the broker
- Download log files from the broker
copy from the Solace CLI to the outside world
To do that, you have to be logged in the CLI.
ena copy logs/event.log scp://user@somehost_or_ip/tmp copy logs/event.log sftp://user@somehost_or_ip/tmp copy scp://user@somehost_or_ip/create.cli cliscripts/ copy sftp://user@somehost_or_ip/create_cli cliscripts/
This solution works for appliances and software brokers, as long as you have access to the cli.
copy from somewhere outside into broker via scp/sftp
scp -P 2222 somefile.cli filetransfer@ip_of_docker:cliscripts/
Keep in mind:
- 2222 is your ssh port for the solace cli and is also used for scp
- you need to configure a filetransfer user to do that in the cli (https://docs.solace.com/Configuring-and-Managing/Configuring-File-Transfer-User-Accounts.htm#mc-main-content)
- you need to authenticate with user/password, because ssh-keys wont work in the docker container
This solution works for appliances and software brokers, as long as you have access to the ssh port.
Copy to the Docker Container
docker cp somefile.cli solace:/usr/sw/jail/cliscripts
Keep in mind:
- this command assumes, that your container is named "solace"
- the "cliscripts"-directory in the cli is mapped to "/usr/sw/jail/cliscripts" inside the container
This solution does not work for appliances, just for dockerized brokers. You need access to the docker host and you need access to docker commands
Map docker containter volumes to the Host system
It is recommended (eg for better update-ability) to map the solace filesystems to the docker host.
You can check that with:
docker inspect solace
Check the "mounts"-section in the output.
Often, you can see something like that:
{ "Type": "bind", "Source": "/opt/solace/jail", "Destination": "/usr/sw/jail", "Mode": "", "RW": true, "Propagation": "rprivate" },
Here, the /usr/sw/jail directory inside the container is mapped to /opt/solace/jail on the docker host.
On the docker host, you can just copy files like this:
cp xxx.cli /opt/solace/jail/cliscripts
You can even copy from outside:
scp xxx.cli myuser@dockerhost:/opt/solace/jail/cliscripts
This solution does not work for appliances, just for dockerized brokers with named mapping for docker volumes. You need access to the docker host.
Comments
-
@uli A great article. One point to add is that you have to create a "file transfer" user account. For instance, to do:
scp -P 2222 somefile.cli filetransfer@ip_of_docker:cliscripts/
You'll need to have an account with name "filetransfer" created with file transfer permissions. See Configuring File Transfer User Accounts for more details.0 -
Excellent post! Thanks.
BTW, i think it's also better to use docker cp to copy the certificates into the broker instead of using sftp (as per the Solace documentation - Managing Server Certificates).docker cp mycert.pem solace:/usr/sw/jail/certs
3