Search code examples
rsync

Rsync - How to display only changed files


When my colleague and I upload a PHP web project to production, we use rsync for the file transfer with these arguments:

rsync -rltz --progress --stats --delete --perms --chmod=u=rwX,g=rwX,o=rX

When this runs, we see a long list of files that were changed. Running this 2 times in a row, will always show the files that were changed between the 2 transfers.

However, when my colleague runs the same command after I did it, he will see a very long list of all files being changed (though the contents are identical) and this is extremely fast.

If he uploads again, then again there will be only minimal output.

So it seams to me that we get the correct output, only showing changes, but if someone else uploads from another computer, rsync will regard everything as changed.

I believe this may have something to do with the file permissions or times, but would like to know how to best solve this.

The idea is that we only see the changes, regardless who does the upload and in what order.

The huge file list is quite scary to see in a huge project, so we have no idea what was actually changed.

PS: We both deploy using the same user@server as target.


Solution

  • The t in your command says to copy the timestamps of the files, so if they don't match you'll see them get updated. If you think the timestamps on your two machines should match then the problem is something else.

    The easiest way to ensure that the timestamps match would be to rsync them down from the server before making your edits.

    Incidentally, having two people use rsync to update a production server seems error prone and fragile. You should consider putting your files in Git and pushing them to the server that way (you'd need a server-side hook to update the working copy for the web server to use).