Blog indexRolling🥎blogPermalink

rsync is really good

Jake Thoughts31 Dec 2020 16:24:44 -0500

Hey you! Have you ever put all your website files into a .tar.gz then sftp that .tar.gz onto the target machine then ssh into that machine then un-tar that file then mv those files to the correct location? No? You have not? Oh, yeah, I have not either..... t-totally... 0.0

Okay, okay, I have. But that is because I did not know about rsync, I mean I knew it existed, I have seen some people mention it. But no one ACTUALLY shills for it. At least not from what I have seen.

I really wish I knew about this earlier. Honestly, all these cool tools make my life easier. I cannot imagine not using rsync now.

Hopefully you already know something about rsync, aside from its name of course. I will show you every line of code that I use to update my website... It's pretty hardcore to be honest.

$ rsync -rlEp web/jakesthoughts.xyz/jakesthoughts/ jakes_nfssh:/home/public/

Yes, literally, that is all I have to do to update my website now. You can determine what the flags mean if you look at the man page.

To clean up leftover junk I would use --delete. My one test with the delete flag shows that it does, in fact, delete files in the remote directory that do not exist in the source directory.

The jakes_nfssh: bit is a... ssh config thing? Here is an example:

$ cat ~/.ssh/config
host *_nfssh
    Hostname ssh.phx.nearlyfreespeech.net
    Port 22

host jakes_nfssh
    User my_username

This little trick allows you to $ ssh jakes_nfssh without having to type in the IP address/url. You can create more 'User' sections so you can login with other users. Requires your public ssh key or, probably, a password.

I am sharing this information because rsync works with ~/.ssh/config which makes my life easier.

From my understanding, admittedly brief, rsync uploads files that are somehow different into the target directory... So I do not need to worry about uploading files that do not need to be uploaded. For (n/g)eocity users... I doubt that you have an rsync option. Neocities seem to have the power to upload by cli but it isn't rsync. Requires Ruby and downloading a gem...

rsync can be used on the command line so it is possible to write scripts with it in mind. Maybe make an alias that rsync's your website in ten (10) keystrokes, like: $ updatesite.

I wrote this piece because I ignored rsync because I thought it was a meme. I cannot and will not go back to my old method. Hopefully, if you are not using rsync, this piece will convince you to try it out. It is super easy to use.


For more information regarding rsync visit: https://rsync.samba.org/

Other thoughts

Arlonooo on 2021-01-01,06:29:41 said:

Idk what this means, but I'm proud of u, dude.

ty on 2021-01-12,02:20:26 said:

jake <3

jake on 2021-01-14,05:19:06 said:

ty <3 (pls fix ur site)

th3g3ntl3man on 2021-01-31,10:09:00 said:

Good read, nice job Jake.

Play_it on 2022-02-12,00:40:20 said:

Nice, but is rsync not just a fancy scp?

Jake on 2022-02-12,07:30:59 said:

That is one way of saying it. One feature that rsync has is that it detects which files have changed and WHERE it was changed and uploads that. Meaning less bandwidth usage overall


Be sure to submit your thoughts! Emoji Ledger (hover mouse over)!