Import images from one site one the same Trellis Server to another


#1

How do you guys deal with moving files from one site on the same Trellis server to another? I need to move images from one site under the main domain to a site under a subdomain on the same Digital Ocean Droplet setup with Trellis.

Do you use SCP or wp-cli and if so how? Does a command like

wp media import /srv/www/domain.com/current/web/app/uploads/*
from destination site work going through all folders and importing images to media on site from where the command is fired?

Or do you use something like scp -r (not worked out the entire command yet and is more useful from server to server)
Or better yet cp it seems and:
cp /srv/www/domain.com/current/web/app/uploads/* /srv/www/subdomain/current/dest

and then import with the Add Server plugin for example?


#2

I use rsync. In the example below, example.com is the source remote server and howdy.com is the destination remote server. Run this command from your host machine:

ssh -o ForwardAgent=yes web@example.com "rsync -aze 'ssh -o StrictHostKeyChecking=no' --progress /srv/www/example.com/shared/uploads/ web@howdy.com:/srv/www/howdy.com/shared/uploads/"

#3

… I just FTP them all down and then FTP them all back up to the new location.

… I am ashamed.


#4

This post has a playbook for uploads: Pushing or pulling uploads with Trellis