Trellis Rsync Media

To quickly sync media from one Trellis server to another to copy media you can rsync media. Using the cli too rsync you can copy media from one server to another with one command from the terminal

Base Command

From one a Trellis server to another you can use rsync. You have to make sure you start with the source and then add the destination:

ssh -o ForwardAgent=yes "rsync -aze 'ssh -o StrictHostKeyChecking=no' --progress /srv/www/"

Now let’s get into detail on the command here shall we?

First SSH Command

As you can see we have multiple ssh parameters:

  • -o options – allows you to add ssh options
  • ForwardAgent= yes – option added to make ForwardAgent work so we can ssh into destination after ssh-in into source without stoppping

Rsync Setup

We also have rsync itself with a few parameters:

  • a – archive mode
  • z – gzip compression
  • e – specify remote shell to use

Second SSH Command

The second ssh command also using the option parameter but now indicates StricHostKeyChecking as ‘no’ and with progress.

… when you do ssh to a machine for the 1st time (or whenever there is a key change in the remote machine), you will be prompted to say ‘yes’ for authenticity of host. Geek Stuff Source Article

So to avoid this and make sure things go smoothly we turn this off in this command. So not permanently in the sshd_config.

NB Post inspired by Ben’s Post

Tagged in : Tagged in :
Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.