To do a Laravel Sync Remote Files to local Homestead Vagrant box you can use rsync. And you should use it over scp or sftp because it is way more efficient.
Well, there is an awesome SO thread on this. And I will quote Rafa:
rsyncwill check files sizes and modification timestamps of both A and B, and skip any further processing if they match.
- If the destination file B already exists, the delta transfer algorithm will make sure only differences between A and B are sent over the wire.
rsyncwill write data to a temporary file T, and then replace the destination file B with T to make the update look “atomic” to processes that might be using B.
As you can see this is way more efficient than sftp or scp because that is basically dumm copying of files and overwriting what you have already.
The rsync command I use is:
rsync -chavzP --stats firstname.lastname@example.org:/var/www/domain.com/shared/public/uploads/* .
Here a couple of remarks on this:
- We assume you are in the directory locally where you want to store files. In most cases that is public/uploads/.
- Two, we use user web here, but on your server or a Laravel Forge server this will be another user entirely.
Now on the flags -chavzP:
- c checksum
- h human readable
- a recursion and preserve almost anything
- v verbose
- P partial progress
- stats print a verbose set of statistics
It will look like something like:
rsync -chavzP --stats email@example.com:/var/www/domain.com/shared/public/uploads/* . receiving file list ... 1225 files to consider 1/ 1/rotate_mobile.png 33.14K 100% 31.61MB/s 0:00:00 (xfer#1, to-check=1223/1225) 1/rotate_mobile_thumbnail.jpg 1.60K 100% 780.76kB/s 0:00:00 (xfer#2, to-check=1222/1225) 100/ 100/2001356401.png 141.57K 100% 1.05MB/s 0:00:00 (xfer#3, to-check=1220/1225) ......
Bonus Trellis Usage
If you are using Roots Trellis and would like to sync all files from the production server you can use the same command from the local uploads folder. Just a different path really:
rsync -chavzP --stats firstname.lastname@example.org:/srv/www/domain.com/current/web/app/uploads/* .