r/linuxadmin • u/Ok_Animator_1770 • Mar 13 '26
Why you should use rsync instead of scp in deployments
I ran a few real-world measurements deploying a ~350 MB static website with about 1300 files, and tested it locally with a Bash script and in a Github Actions workflow.
It turns out that just by switching from scp to rsync you can save significant time and network traffic.
Github Actions: scp 43 seconds, rsync 10 seconds and ~14x less network traffic.
Bash script over LAN WiFi 5: scp 188 seconds, rsync ~15 seconds.
I wrote a concise article describing the process and included a clear table with measurement results for scp, tar + SSH, and rsync.
The Bash scripts and Github Actions workflows are included and available for reuse or for reproducing the measurements if anyone is interested.
Here is the link to the article:
https://nemanjamitic.com/blog/2026-03-13-rsync-scp
What tricks do you use to optimize deployment performance? I am looking forward to your feedback and discussion.
112
u/DevLearnOps Mar 13 '26
Am I the only one that thinks that
rsync-ing your files into the server is not a good deployment practice?Yes,
rsyncis amazing for transferring files, all my backups usersync, though I would never do deployments this way. Build a package, store it somewhere that has versioning, push/pull the package into the server (ideally ephemeral), toggle release. Done. Syncing files into the server is just moving from an inconsistent state to the next with no options for rollback.42
u/notdedicated Mar 13 '26
This whole deployment strategy you have is ... eek. Clearing the destination and dropping new files? That is definitely not the way to do a release, package the whole thing and deploy, then when complete update links / references to the new deployment path. Rollback? Switch links back. Failed copy? No harm done, do it again. Eek. I mean at the very least you should SCP/Rsync to a staging path then move it into place if you can't use links or change references.
You lost me the moment I saw you deleted all the files on the destination before copying..
Also, tar isn't compression, it's packaging. gzip is compression often used together in *nix as gzip is focused on single file in to out.
8
u/HeligKo Mar 13 '26
I love rsync for many things, but when doing anything that qualifies as a deployment I want more confidence that I can demonstrate things went right. A tar file with a hash for verification has been pretty standard linux deployment model. I would use something more like this for production work.
13
u/jippen Mar 13 '26
Why not just use git pull at that point- with the images and such in git lfs? Seems like it might be far faster and you can easily audit for differences between the copies on machine and in the source of truth?
8
u/Amidatelion Mar 14 '26
What are you scp/rsyncing deployments for in 2026? Why is this not coming from a secured artifact repository? Why is deployment time even a concern for you? Why is a section of your tests WiFi??!?
Hmm.
At this junction, I would propose narrowing your focus to improve on your core skillset. Good luck.
3
u/Gendalph Mar 14 '26
rsyncis amazing, but I haven't seen raw file deployments for more than half a decade. At minimum usegitand a deployment key, then dogit pulland check out a tagged release. Or use containers and, ideally, do blue/green deployment.Yes, this is more cumbersome, but this is what's done in real world.
3
u/getpodapp Mar 15 '26
What year is this lol, 2003?
2
u/Logical_Sort_3742 Mar 14 '26
Well, I see lots of people talking about deployment methods and giving you hell over that. I think that is unnecessary. I work in a company with lots of systems with different levels of isolation, and sometimes "just use git" does not make sense if you are deep into the ICS.
I am here to say thank you, because I learned something. I use scp and rsync both, but never realized the size of the performance gap. Now I do.
2
u/ZexGr Apr 10 '26
thank you for this aricle.
Хвала на детаљисању око Докера
1
u/vogelke Mar 14 '26
If you control the development and production servers and you can install aide, it's an excellent way to see changes in a directory tree or file collection.
You can run aide on a set of files and get a database holding file metadata and content hashes. If you make some changes and generate a second database, you can compare them and quickly see a list of modified files.
Feeding this list to rsync can be much faster than syncing two directories over a network -- rsync can get lost in the weeds if you give it a large enough tree.
I have an example here:
https://bezoar.org/posts/2026/0314/changed-files/
1
u/FromOopsToOps Mar 18 '26
You guys know that developing a backstage is a thing and using rsync in the backstage to deploy something somewhere is alright, right?
1
u/ReallyEvilRob Mar 15 '26
scp is actually deprecated.
0
u/toarstr Mar 15 '26
April the 1st is still a few weeks away, stop it.
-10
u/[deleted] Mar 13 '26
[removed] — view removed comment