Linux/Mac Terminal Tutorial: How To Use The rsync Command - Sync Files Locally and Remotely

In this Linux/Mac terminal tutorial, we will be learning how to use the rsync command. The rsync command will allow you to sync file and directories on your local machine or even over a network between servers. This is a great tool for running back ups, for only copying diffs, or even for deploying segments of code. Let's get started.
VirtualBox Network with SSH: • How to Create a Networ...
Key-Based Authentication: • Linux/Mac Tutorial: SS...
Cron Jobs: • Linux/Mac Tutorial: Cr...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Linux #Mac

Пікірлер: 182

  • @RinksRides
    @RinksRides5 жыл бұрын

    right out of the gate, glad there's no stupid background music!

  • @RsZ789

    @RsZ789

    4 жыл бұрын

    And no 20 second annoying intro. Love it.

  • @Gobi-Wan

    @Gobi-Wan

    4 жыл бұрын

    @@RsZ789 dont forget to like comment and subscribe!

  • @huntercoleman1347
    @huntercoleman13476 жыл бұрын

    One of the best rsync tutorials ever. Thank you.

  • @easyvideott7505

    @easyvideott7505

    3 жыл бұрын

    NO... this IS the best tutorial on rsync!

  • @choppy1356
    @choppy13563 жыл бұрын

    I really appreciate your approach -- everything you said was about rsync -- no rambling on an on. A short description up-front, then useful examples following a planned presentation. Informative and straightforward.

  • @kimlien637
    @kimlien6376 жыл бұрын

    Wow, I'm a huge fan after viewing that. Been having a hard time understanding rsync, but love all your examples! Please keep adding videos like these!

  • @morecrapz
    @morecrapz6 жыл бұрын

    Thank you so much. By far the best tutorial I have seen about rsync. Great job!

  • @alanmead9830
    @alanmead98305 жыл бұрын

    Very clear and I liked the illustration for --dry-run. I'm also in awe of your typing skills (almost 18 minutes and not one typo!). But I'd be careful of calling rsync a backup tool. While rsync makes a copy, proper backups should be versioned so that if you accidentally damaged a file a couple days ago, you can get a clean copy from the backup made three days ago. If you rsync nightly to a destination copy, the damaged version of the file would already be synced by the time you realized it was damaged. You can add versioning to rsync (and --link-dest=dir can make it very space-efficient on the backup host) but you need to add a process for maintaining versions. Basically, to get seven days of versioning, you should rsync to a rotating day-of-the-week destination folder. But just rsync'ing to a single destination folder (as shown here) would not be versioned and would not be a good substitute for proper (versioned) backups. But a great explanation of using rsync.

  • @smile768
    @smile7684 жыл бұрын

    Fantastic video! Imagine the hours I could have saved doing drag and drop manual backups if I’d seen this before! The dry run is such a useful feature and gets rid of the ‘clenching’ anxiety when you’re not sure that your backup is going to do what you thought it might. Thank you.

  • @mykolaservetnyk640
    @mykolaservetnyk6403 жыл бұрын

    For those who read comments, before watching: it is exactly the tutorial you were looking for: good vid quality, good English, good examples. Thank you, Corey Schafer!

  • @alanjoyce9290
    @alanjoyce92906 жыл бұрын

    I’ve never felt so excited about watching more videos, if your other videos are as well put together and informative and easy to understand as this I’m going make some popcorn and tea :) good work and thanks for information it will be very helpful.

  • @markwon8945
    @markwon89454 жыл бұрын

    this is a great tutorial... i really like how you emphasized the --delete option. That would be catastrophic in a moment where you're trying to improve efficiency. Thank you!

  • @diegosandoval2043
    @diegosandoval20435 жыл бұрын

    Perfect tutorial. You explained exactly what I needed to know.

  • @therimalaya
    @therimalaya5 жыл бұрын

    After a long time, I am satisfied with what I have learned. So many things but you made it simple and easy to understand.

  • @shubhankargahlot
    @shubhankargahlot3 жыл бұрын

    Have been trying to read about rsync since last few weeks with nothing to stick in my mind. Thanks for being crisp and clear.

  • @benjaminmoseslieb9856
    @benjaminmoseslieb98562 жыл бұрын

    Great tutorial! Much appreciated. I like your style. Direct, to the point, and accounting for all the things someone needs to understand who's new to this. A natural educator.

  • 6 жыл бұрын

    Excellent step by step rsync demonstration video from a simple way to a complex way. Very useful, thanks a lot, Loïc.

  • @sergiobeltrao
    @sergiobeltrao6 жыл бұрын

    Awesome! I did my personal scripts and binding to specific shortcuts so I can sync some directories with just two or three keys. Thanks for the video it provides me with all the information that I still need to accomplish that.

  • @DiwakarKankipati
    @DiwakarKankipati3 жыл бұрын

    One of the best explanatory video on rsync, the presentation was good and the commands are clearly visible

  • @suryatejareddymallidi110
    @suryatejareddymallidi1103 жыл бұрын

    You just saved my day with this tutorial. Was fed up completely and thought of getting rid of rsync and implementing custom solution. This tutorial helped me realize my silly mistake and made my day.

  • @EddieK563
    @EddieK5633 жыл бұрын

    Ok, so its now 23rd of September 2020 (Year of the Covid-19) and I am 100% not a Linux guy for sure, but I am getting there with this kind of help. I have just followed this tutorial for Ubuntu 20.04 and have to say, it is still very much current. Thanks Corey, I have subscribed and you will now be my no 1 go to for my tutorials, if you have what I am looking for. Superb examples all the way through. Oh, and this is the first review I have ever felt the need to give in all my time on youtube. thumbs up mate, thank you from the UK.

  • @BryTee
    @BryTee4 жыл бұрын

    I have a lot of experience using rsync, and found some things to do around rsync that get around issues, especially to do with "big" files. How big is big is debatable, it depends on disk size, bandwidth, etc. Anyway... Firstly if a big file is moved from one location to another, as rsync (with the --delete option) does not search for every file to delete before copying files somewhere earlier in the tree, it is possible if the file is big enough that the big file is transferred and fills the source disk before it gets chance to go to the part of the tree to delete where the file used to be. Solution... Do a one time pass of purely deleting files before running the normal rsync, ie: rsync -av --delete --ignore-existing --existing SOURCE DESTINATION Secondly, if the connection is of great distance and data transfer rate is slow, it is possible the rsync TCP connection is dropped before it completes copying a big file. rsync will then delete the half copied file, and the next run suffers from the same issue, and the file never gets copied. Solution... Use --append-verify so that if a timeout occurs, the next run of rsync continues from where it left off. However --append-verify will not copy files of the same (or smaller) size, this can happen with a logfile that might change content and be the same size every run. Or with repodata XML files. Solution... Once the --append-verify run of rsync successfully completes, THEN run a normal rsync (without --append-verify) to ensure files that have different content or are smaller, get copied properly. However this runs into the problem of the file that needs to get copied is BIG and doesn't make it across and it's too easy to get into a situation where --append-verify is ok, but the final rsync is not ok, repeatedly, and a big file never gets copied. Solution... monitor this normal rsync (ie the one after the --append-verify) and if it fails delete the last file being copied on the destination system, and let the next run of this (say) cronjob start again and --append-verify will copy over the big file (in several steps). FYI: I recommend the use of --conntimeout and --timeout to make rsync timeout if the connection hangs or has trouble starting. You might want to put a "timeout" command to call rsync anyway, in case rsync gets into a hung state internally. Finally, this does not solve the issue of a timeout happening if the time it takes for the directory tree to be completely read is too long. rsync will half die, and it's difficult to see why. In that case, split the transfer into multiple sub directories trees, so the directory listing is not too big for rsync to end up timing out during startup.

  • @rfrancoi
    @rfrancoi5 жыл бұрын

    Damn.... EXCELLENT tutorial. I'm speechless.

  • @jeylful
    @jeylful5 жыл бұрын

    Hey mate, great video... subscribed! I will be checking the rest of the videos that you suggested. I started using rsync but now I understand it better. Great explanation! Cheers.

  • @tigrankhachaturian8983
    @tigrankhachaturian89832 жыл бұрын

    Thank you for these. A good place to start learning a command, because the man pages are convoluted and impossible to read, but with you, it's all pretty clear

  • @AlejodelosReyes
    @AlejodelosReyes3 жыл бұрын

    Well, definitely this tutorial was exactly what I was looking for. It took me maybe half an hour to whatch it and write down the concepts, but I'm sure I won't forget your lessons. *Very* good ide to advice to be careful with the --delete flag. I'm looking to do bidireccional syncing and it seems like this is exactly the tool. Already liked your video. Thanks a lot!

  • @kjetilbergtun
    @kjetilbergtun5 жыл бұрын

    Corey, I have been learning about coding and linux for the last three years, and I always come to your channel first to see if you have the content I am looking for. I just donated $20 through PayPal. I know it`s not much, but at least a small tolken of my appreciation. I just bought a Raspberry Pi and looking forward to your upcoming tutorials on this topic :)

  • @coreyms

    @coreyms

    5 жыл бұрын

    Thanks!

  • @a_maxed_out_handle_of_30_chars
    @a_maxed_out_handle_of_30_chars2 жыл бұрын

    thank you, I come back to this video to brush up the commands and their meanings :)

  • @BrianThomas
    @BrianThomas3 жыл бұрын

    Awesome tutorial. Clear, direct, and very easy to follow.

  • @nobodycares3900
    @nobodycares39002 жыл бұрын

    Man, I had to do a hw assignment on rsync. This video literally answered all of the questions that i had. Thanks a lot.

  • @j83lin
    @j83lin4 жыл бұрын

    Excellent description! Love the visual on the right.

  • @gnuPirate
    @gnuPirate Жыл бұрын

    Beautiful video! Great demonstration. Really showed me what I need to know to get rolling with it. Much appreciated

  • @shihabkhan3218
    @shihabkhan32185 жыл бұрын

    Wow. This video was so smooth. Great job buddy! (y)

  • @feerozbthapa
    @feerozbthapa6 жыл бұрын

    Liked, Subscribed and thump Upped. Great video man. Keep it coming.

  • @markslima1557
    @markslima15574 жыл бұрын

    Quick tip for Mac OSX terminal users - when doing rsync (or scp for that matter), you can just drag folders for FROM and TO into your terminal to save time typing. So type your rsync command followed by a space, then drop your origin folder onto terminal and path will appear, (plus an unseen space) then drop your destination folder and enjoy.

  • @ScottCov
    @ScottCov Жыл бұрын

    Corey your videos have helped me a lot...especially the ones on Rundeck..Ty!

  • @mohamedamine94
    @mohamedamine945 жыл бұрын

    this is what we call a greaaat job ,thanks man ,i really appreciate this work

  • @peteallennh
    @peteallennh4 жыл бұрын

    Wonderful presentation Corey!

  • @yhauzeur
    @yhauzeur5 ай бұрын

    Love your videos.. I need come back again, and again through time..

  • @henik9
    @henik95 жыл бұрын

    Thanks man, helped me understand rsync much better.

  • @fabioPatroni
    @fabioPatroni5 жыл бұрын

    Excellent tutorial! I did not know about the --dry-run parameter. I also like to exclude some folder when I am backing up my PC. I use after the --dry-run: --exclude={/sys/*,/tmp/*}.

  • @linuxxxunil
    @linuxxxunil Жыл бұрын

    recently picked up an old nas and nas is new to me. the nas does have apps and one is a sync utility but it's confusing and over documented. Your video was crystal clear. Thank you.

  • @ankan2088
    @ankan20884 жыл бұрын

    Hey Corey I really like your videos, concise and quite in-depth, but I wish you included the --include and --exclude since they get quite confusing.

  • @Lunolux
    @Lunolux2 жыл бұрын

    nice video, didnt feel it was 18min, very clear thx.

  • @nisarggandhi4672
    @nisarggandhi46725 жыл бұрын

    Very good rsync tutorial. Thank you.

  • @romanykemp9042
    @romanykemp90423 жыл бұрын

    Great video. Ditto to the comments made by someone that there is no background music. A lot of information presented quickly and clearly...

  • @seeker-of-knowledge-777
    @seeker-of-knowledge-777 Жыл бұрын

    This helped out immensely. Thanks so much!

  • @lowdownbeats5688
    @lowdownbeats56885 жыл бұрын

    Awesome video tutorial. Thumb up and subscribed!

  • @eitsirk11
    @eitsirk115 жыл бұрын

    Great tutorial. Very helpful!

  • @binaybhushan1192
    @binaybhushan1192 Жыл бұрын

    Fan !! Take a bow , what an explanation, helped to get a task done 😎🥂

  • @AbhishekNigam
    @AbhishekNigam4 жыл бұрын

    Excellent video! Thank you!

  • @Moglichkeitz
    @Moglichkeitz6 жыл бұрын

    Great tutorial Corey! Subbed

  • @MrDaylight
    @MrDaylight4 жыл бұрын

    Very clear demonstration thank you

  • @raquebulhasan9804
    @raquebulhasan9804 Жыл бұрын

    Nice presentation. I really understand this topic. Thank you.

  • @MichaelMagakwe
    @MichaelMagakwe4 жыл бұрын

    Thank you. very useful to my migration process.

  • @BrianThomas
    @BrianThomas5 жыл бұрын

    You have a gift sir thank you very much for your videos it was extremely useful

  • @user-pm4vd6ij8i
    @user-pm4vd6ij8i3 жыл бұрын

    Crystal clear! Thanks!

  • @nonnativeme
    @nonnativeme2 жыл бұрын

    Thank you for this awesome tutorial. 👍

  • @smeagols_smelliest_smuggler
    @smeagols_smelliest_smuggler Жыл бұрын

    Excellent tutorial! Thankyou!

  • @dipankararora2633
    @dipankararora26334 жыл бұрын

    Your videos are too good. Thank you.

  • @xxkeralo6489
    @xxkeralo64893 жыл бұрын

    such a great video good examples and everything important explained Thank you!

  • @Spxs98
    @Spxs983 жыл бұрын

    Thank you, this has helped me a lot.

  • @spaceiswater6539
    @spaceiswater65394 жыл бұрын

    Awesome video Corey thank you so much.

  • @clarkx86
    @clarkx863 жыл бұрын

    Quality tutorial! Thanks!

  • @alterguy4327
    @alterguy43275 жыл бұрын

    This is what i wanted ThankYou

  • @ashgupta854
    @ashgupta8546 жыл бұрын

    One other option I like to use is --stats. This gives a summary of files/folders which have been created, deleted, modified, etc. along with some other info.

  • @dengzhonghan5125
    @dengzhonghan51252 жыл бұрын

    Wonderful video, thanks.

  • @christiandrewitz237
    @christiandrewitz2376 жыл бұрын

    thanks! It is good explained, very useful

  • @mickaelriga8169
    @mickaelriga81694 жыл бұрын

    Great video ! The number of options for rsync could be quite intimidating. It should not discourage people from using it because it is a great tool. It is a good candidate for an alias with tailored defaults for specific scenarios.

  • @alfx4356
    @alfx43563 жыл бұрын

    the best teacher, as usual!

  • @samr6148
    @samr61485 жыл бұрын

    Very helpful! Thank you!

  • @Linuxenthusiast
    @Linuxenthusiast2 жыл бұрын

    Great video. Thank you!

  • @Mrmarcie
    @Mrmarcie5 жыл бұрын

    Very clear, thanks.

  • @EngTeacherHK
    @EngTeacherHK5 жыл бұрын

    Wow!! Thank you so much!!

  • @tkadado
    @tkadado Жыл бұрын

    fantastic tutorial!

  • @NobitaHunMe
    @NobitaHunMe2 жыл бұрын

    Thanks my project done ❤️

  • @dgisindahouse
    @dgisindahouse3 жыл бұрын

    Thank you for this tutorial

  • @nasser_omar
    @nasser_omar5 жыл бұрын

    Good job Bro ....Thanks a lot ..thanks

  • @greob
    @greob6 жыл бұрын

    Don't forget to use the -X flag to preserve extended file attributes!!! "rsync -aXP" Also some GUI frontends / alternatives: FreeFileSync (www.freefilesync.org ), Unison (www.cis.upenn.edu/~bcpierce/unison/ ), Synkron (synkron.sourceforge.net ). Be aware that they don't preserve xattr though.

  • @zaidgharaybeh8422
    @zaidgharaybeh84223 жыл бұрын

    Best tutorial ever

  • @noctua7771
    @noctua77716 жыл бұрын

    Please make Java tutorials after this series. You have some of the most well explained content I have ever had the pleasure of watching. Keep it up!

  • @Habaneroranger
    @Habaneroranger3 жыл бұрын

    Would love to see you explain rsync excludes

  • @TuxHouseEdu
    @TuxHouseEdu2 жыл бұрын

    Thank you so much!!!!

  • @hornstrum
    @hornstrum3 жыл бұрын

    VERY GOOD! > U got me back into [terminal] > now to re-learn how to colorize my terminal and all that stuff. Thanks again. #HHNET

  • @madanjitender
    @madanjitender3 жыл бұрын

    This Video is Great !

  • @rajnilguha1036
    @rajnilguha10366 жыл бұрын

    Thanks for this video, really rsync is a great command and I have been using it a lot lately. If you could do a tutorial on linux networking commands then that would be of great help as well. Thanks.

  • @Theborg72
    @Theborg723 жыл бұрын

    wonderful video is possible .if I have a home folder with subfolders, in them there are different files. now I want to copy only the files in all folders to a destination folder.

  • @pankajkharade6936
    @pankajkharade69363 жыл бұрын

    Excellent 👍👍👍👍👍

  • @jchuri
    @jchuri2 жыл бұрын

    Very useful

  • @gulruhahmedova9456
    @gulruhahmedova94563 жыл бұрын

    thank you very much

  • @rmcellig
    @rmcellig6 жыл бұрын

    Great video!! Regarding entering the IP address is see, can I put the hostname instead?

  • @PeteMEHO
    @PeteMEHO3 жыл бұрын

    Superb video. Just subscribed. Does rsync notice if the file sizes are different. For example, if I’ve added more photos into iPhoto. The file would be there b the size is different and copy it over?

  • @deepthitheresa1
    @deepthitheresa15 жыл бұрын

    Very nice tutorial. If you use the -z parameter to transfer a large sized file(in GBs after compression), when the next time it will run, whether rsync can detect the changes happened inside the compressed dir and sync only changes? Or every time it will sync the whole file compressed file?

  • @erickmwazonga8871
    @erickmwazonga88716 жыл бұрын

    Thank you very much for this detailed tutorial. However, I would like to ask how to use rsync between 2 servers to local machine..i.e a server that is accessed through DMZ to your local machine.

  • @samuelmiller1691
    @samuelmiller16913 жыл бұрын

    bruhh just lost my entire external drive to a MARS ransomware attack and I had no backups on my Pi. This is so helpful

  • @ShikaiXu
    @ShikaiXu Жыл бұрын

    hi Corey, thanks for your vid, you really helped me understand rsync. I'm new to linux and plan to moving (my server) from macOS to Linux. Most of apps/softwares now I've found the Linux version/solution, only leaving the backup solution unsolved. I love the time machine from macOS, it not only backup the files automatically, it also keeps version of the entire mirror. For example I can go back to the history of a file/folder hours/days/weeks earlier. I wonder if rsync do this? By watching your vid I now understand rsync can do archive copy with -a, but looks it only filters the file to copy, but what I want is to keep history versions of a file/folder, is it possible to go with rsync? Thanks.

  • @_diversitydiaries
    @_diversitydiaries2 жыл бұрын

    Great Tutorial! I have learned very much! Q: If i made cron job on daily basis for rsync the directory. And in the directory there is lots of content which will take around 2-3 days to complete. But my cron job will run on daily basis. So will my server get crash or get load or anything will going wrong ?

  • @ascarpio
    @ascarpio4 жыл бұрын

    Hi Corey, I appreciate your videos and find them very useful. However, can you use rsync to move only files that are older than x days to another server?

  • @ammarulhaq9790
    @ammarulhaq97903 жыл бұрын

    I heard about the legend Corey for Python and decided to check him out later now I'm here looking for Rsync to make backups offline and here we are on his channel and subscribed to him

  • @russellrussell5495
    @russellrussell54953 жыл бұрын

    Perfect.

  • @SuperRunescap
    @SuperRunescap6 жыл бұрын

    Thanks for yet another tutorial! Deja vu 6:19 - 6:38 ^^

  • @coreyms

    @coreyms

    6 жыл бұрын

    Whoops. Thanks for noticing that. Definitely an editing error. I listen to these multiple times before uploading them, but sometimes it all runs together and I still end up missing things like that.

  • @coreyms

    @coreyms

    6 жыл бұрын

    I'm trying to use KZread's built-in trim tool to edit out the duplicate, but it's pretty rudimentary. Not sure if it will sound natural once it finishes with the edit, but we'll see.

  • @coreyms

    @coreyms

    6 жыл бұрын

    Okay, that seems to have worked and the duplicate soundbite has been trimmed out. Thanks again for letting me know!

  • @SuperRunescap

    @SuperRunescap

    6 жыл бұрын

    No problem! ^^

  • @theobican5971

    @theobican5971

    6 жыл бұрын

    Corey Schafer B

  • @griffinb2008
    @griffinb20086 жыл бұрын

    Kind of reminds me of scp in a way. Great video!

  • @coreyms

    @coreyms

    6 жыл бұрын

    Yes, it's similar. But it's a bit better for certain situations where you only want to sync the diffs, such as backing up large numbers of files or images.