🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

How to copy files to/from a Solace broker

uherbst
uherbst Member, Employee Posts: 130 Solace Employee
edited October 2020 in Tips and Tricks #1

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:

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.

Tagged:

Comments

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin

    Awesome, thanks @uherbst! This will post will definitely come in handy for me :)

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    @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.

  • CloudGod
    CloudGod Member Posts: 24 ✭✭
    edited October 2020 #4

    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
    
  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    Good point @CloudGod, the only point being the sftp method works no matter where the broker is deployed, whereas docker cp only works with docker. That's why I tend to use sftp.