Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tzookb's avatar

deploy with rsync

does somebody here deploys with rsync?

if so how is your script "excludes"

how do I handle the storage/logs, storage/app/cache etc folders

0 likes
2 replies
fideloper's avatar

Sure, deploying over rsync is fairly straight forward. It is basically just a way to move files. Rsync will check file differences and only upload files that have changed.

Here's what I use typically - something like this:

rsync -vzrS --exclude=".*" --exclude="node_modules" --exclude="publish.sh"  /pathto/local/code user@remote-host:/var/www/remote-website

This will:

  • Exclude dot files (such as .git dir, .gitignore file, etc), node_modules and the publish.sh file (where I keep the above script)
  • -vzrS - Verbose, Compress, Recursive, Sparse files (google that one)
  • user@remote-host would be the same way user/host you use to SSH into your server

As for handing storage/logs and cache. Rsync will copy over from your local files to remote, so you may get some local log files in your remote server, unless you exclude those files when deploying over rsync. I think you should be able to exclude those via more --exclude flags.

Last note: Rsync implies that you have SSH access to your server, so consider using rsync to send files locally, and then using something like fabric or envoy to run any additional needs, such as reload php-fpm or restarting queue jobs. Envoy/Fabric and similar SSH task runners can run commands on the server, while rsync can only push and pull files to/from a server.

3 likes
tzookb's avatar

Thanks @fideloper !

great to get a response from you, the one I learned rsync and many cool server stuff!

now I use this:

 rsync LOCAL_PROJECT REMOTE_PROJECT -alz --delete --exclude-from=excludesFile

and this is my excludesFile:

bootstrap/cache/*
.env
.idea
.git*
node_modules
storage/framework/cache/*
storage/framework/session/*
storage/framework/views/*
storage/logs/*
storage/app/*
5 likes

Please or to participate in this conversation.