Posted on Leave a comment

How to sync wordpress uploads folder with local environment.

rsync -v -a -e 'ssh -p 2200' uploads/

// Keep in mind that rsync works left to right (from => target).

// -v verbose lets you know things are happening
// -a archive maintains preserves directory structure
// -e executes a piece of code ( I use it to target a specific port for ssh ).

This snippet will allow you to quickly sync a local directory with a remote one. I’ve used this snippet repeatably to sync large media folders to my location installation of a wordpress site.

You’ll need SSH access to the remote server for this method to work.

Also note that 2200 is likely NOT your port and you should configure it your specific server.



Depending on what you use for your local wordpress environment (I use VVV) – you might want to sync all your remote images with your local installation.

But this might not be easy if you’ve got a large website (like a store) with thousands of images and limited storage on the server. You can’t zip them up because even compressed they are too big!

Rsync to the rescue!

rsync is a wonderful little command line tool which will literally sync a remote directory like wp-content/uploads.

Assuming you’ve got SSH access to a remote site – you can simply specify a port and username to get access to the directory.

rsync -v -a -e 'ssh -p 2200' relative/path/to/local/wp-content/uploads/

Good job you did it

Please not that this may take awhile to complete depending on how big your directory is. I wrote this quick post while waiting for my mine to complete. You can of course continue to developer even with out the images but damn does that get annoying and slow really quick.

Thanks for reading!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.