Using rsync on Mac to Copy Files

There’s a lack of good file copy utilities on Mac like there is for Windows (eg. Teracopy/Ultracopy). If I need to copy a bunch of files where I’m likely to come across errors copying, I’ll use rsync!

This guide covers how to copy files on a Mac using an external drive or any connected network drive. It’ll skip any errors and log all the failed copies to a file for you to check through. It’s especially handy for copying files while skipping errors, corrupted files and getting past some permissions errors.

This is a beginner to intermediate guide and doesn’t cover some of the more advanced features of rsync.

Step by Step rsync for Beginners

Step 1:  Open Terminal.app    It is located in Applications/Utilities/
You can also open it the quick way by going to Spotlight and typing: terminal

Step 2: Type the following into Terminal, but do not press Enter. (note there is a space at the end of the command and the P is a capital letter)

rsync -ahP

Step 3: Drag and drop the SOURCE folder onto the Terminal window. This is the folder that has the items you want to copy.

Step 4: Drag and drop the DESTINATION folder onto the Terminal window. This is the folder you want the files to go to.

Step 5: Add the following to the end of the command (note the space after the destination folder):

2> ~/Desktop/rSyncErrors.txt

Step 6: Press Enter!
You will see the files transferring as they go, if there’s a lot of files it’ll fly by pretty quickly. Just wait until it has finished.

At the end you will see a summary of how much has copied and how fast it went.

Checking for Errors

To Check for Errors, there is a file on your Desktop called rSyncErrors.txt, this will contain any errors during the copy and why they failed to copy.

What does the command mean?

rsync is a really powerful program that can do a whole lot of stuff, the command I wrote above is a very simple one designed to copy data quickly and easily without too much fuss.

Here’s a run down on the different parts of the command:

rsync -ahP {source} {destination} 2> ~/Desktop/rsyncErrors.txt

rsync   — Runs the rsync command

-ahP        — These are called Switches. They tell the program to run with particular options.

a  – This tells it to archive, it will preserve permissions, modified/created dates and any other extra data with the file.

h  – Human Readable. This tells it to display all the values in human readable form (instead of “112543662.08 bytes”, it will show “107.33MB”)

P  – Progress/Partial – This is actually 2 commands in one. Progress will show you the progress of each file as it transfers (so you can see that it’s actually copying data). Partial will resume files that have been inturrupted part way through copying.

2> ~/Desktop/rsyncErrors.txt   – This tells it to send any errors to the file on your desktop called rsyncErrors.txt.

Extra Tips

If you want to cancel an rsync part way through running, you can press Control-C to stop it. It won’t undo anything that has been done though, so you’ll end up with only part of the data copied.

rsync can resume from a failed copy. For example, if you’ve got a hard drive that tends to disconnect randomly, you can redo the command and it will resume from where it left off.

If you’re having trouble with permissions and copying files, you can run the command as sudo (type “sudo ” before the command). This will run it as an Administrator. Though with the settings I’ve specified, it’ll just copy the permissions errors along with it!

Advanced Version

(Skip this if you’re not sure what you’re doing!)
The terminal command to use rsync to copy files is:

rsync -ahP {source} {destination} 2> ~/Desktop/rsyncErrors.txt

Did this work well for you? Any problems?  Please leave a comment below!

56 comments

This worked out great. thank you

I want to thank you for this tutorial! I have an external drive that belonged to my PC when it failed. I have 40,000+ items on it, and finally got an enclosure that allowed the Mac to read the data. I bought an 8TB external and was trying to move everything over for safe keeping.
However, I kept getting those still in use errors. I have been putting it off for over a year because it’s such a pain to go 30 at a time, then skip the errors. I was going to give up until I saw your post.

I have one BIG issue though. Though I am going from one external drive to another, the system seems to want to go through the Mac, and I do not have enough space to handle it, therefore it stops and says there’s not enough room. Why is this? Why can’t it just push all data (skipping over the errors) from one external to another? I have plenty of room on the destination drive. Thank you again for all your help

This is the error

rsync: writefd_unbuffered failed to write 32768 bytes [sender]: Broken pipe (32)
WARNING: Media444/El Jason 2.jpg failed verification — update retained (will try again).
rsync: connection unexpectedly closed (88872 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-51/rsync/io.c(453) [sender=2.6.9]
Chriss-MacBook-Pro:~ chrisyakubovsky$

Hey dude, thanks for reading my blog!
It shouldn’t go through your computer as such, it should just go from one drive to the other. The error you’re getting looks like the drive is dropping out.
The plus side is, just keep running that rsync command (hit up on the keyboard to go to the last command you ran, then enter) and it’ll resume from where it was.

Hope this helps!

Ducky

Hello, than you for the excellent tutorial. Data created is not kept.
I sync MBA Early 2017 with Toshiba Canvio T1, exFat format.

Thank you for your support in advance.

Best, A.

I’m not even sure what you mean by that, did you see any progress as it copied?

duck, thank you for your reply. Yes, the files copy over nicely. File Modified Date and Last Date are kept when files are copied to target folder. The file Created Date changes to Today’s date.
I hope this answers you question.

Any advice?

Best, A.

Ah, yeah I’m not sure about that one, using the -a flag keeps all the date modified etc, but there’s no option for keeping the date created…

I did a bit of googling around and there’s no super easy answer to it that I could see 😐

duck, thank you. I did a bit of googling around myself and found very little. I chosen OS X Extended (Journaled) to format the external drive and ran the rsync -a command. Files are copied over nicely and Created Date, Modified Date and Last Accessed Date are kept.
I thought you would want to know that.
Best, A.

How do you run rsync so it only syncs new or changed files?
Thanks for this tutorial, it really helped.

rsync does this automatically, just run the command again and it’ll only sync new/changed files.

Can you provide instruction on how this script could be run a scheduled basis please?

Hey ducky, good article √√ would you be willing to review Truck.app on your blog? (It’s a drag-and-drop interface for rsync). I’d be happy to send over complimentary keys etc. Always looking for feedback.

It looks alright, I’ll check it out!

MacWhisperer

I’ve tearing my (little) hair out over the past week trying to copy 4TB from a old Drobo that’s gone into Read Only mode (don’t ask about that one!) connected to a 2009 Mac mini across to a new Synology DS1019+ on a Gigabit network. Finder say ’32 days….’ I’ve actually been trying several experiments but this is the first time I’ve tried rsync… What a revelation! I’ve just performed a test on part of the transfer and it’s blindingly fast compared to what I’ve had. Added benefit? It’s skipping unwanted OS files that I can’t delete on the Drobo (worst bit of kit I’ve ever had to use). Thanks so much for the easy tutorial Duck, you may have saved the day…

No worries! Glad I could be of assistance!

Hi Duck. I’m trying to copy all the volume of a time machine drive to a new HD. I tried to follow your instructions, but I had permissions errors:

rsync: opendir “/Volumes/Backup HD/.Spotlight-V100” failed: Operation not permitted (1)
rsync: send_files failed to open “/Volumes/HD Externo 2 MAC/.fseventsd/00000000013c7a39”: Permission denied (13)

This was one line of example. Nothing was copied.
Do you have any tips to solve?

Oops, got distracted and forgot to reply.

Try running it as sudo? Just put sudo before the command you want to run and enter your admin password.

Thanks for the tutorial. I must have messed up though. When trying to copy a Time machine backup (about 225gb) from one external hard drive to the other it said my computer ran out of storage even though I started with 450 gb free. Help please! At least to free back up my computer since it appears to list the now used space under System when I go to manage storage. Thanks in advance.

Let’s just say that this command is humming along nicely transferring 300k+ files from a 2-disk Firewire 800 RAID mirror array with a failed disk to a newly-built FreeNAS box. Should be done any day now!
Thanks, this is just what I needed.

😀 Awesome!

FreeNAS is a beast, I just upgraded my server to 5x8TB HDDs and she’s going well.

will this rsync -ahP {source} {destination} 2> ~/Desktop/rsyncErrors.txt command only copy from old hard drive to new hard drive and NOT delete existing files on new hard drive which are not on old hard drive?

Mike Betteridge

Spot on. I was trying to use cp and failing miserably.

Thanks

Robert Christopher Bullock

You may want to mention the rsync -aP –delete if you are syncing and there are files on the that are deleted from via normal use otherwise those unwanted files will keep building up.

Say, if you are syncing your source on your Mac to a NAS for backups.

Now, that said, Please take a look at my channel such as this Unraid server build video: https://youtu.be/9LxjTxU–iI since I’m out of work and trying to build subscribers to monetize it. 🙂

I’m using rsync to move data off my Drobo 3 to an internal 4TB drive to decommission the Drobo in favor of a combo with that, Backblaze, and Unraid.

How would I copy an entire external drive to another drive (like mirroring for a second backup)?
Thanks in advance; Jeff

Thank you Duck, your tutorial was perfect.
It worked perfectly on my iMac ran it on a PC with Ubuntu and rsync went like a rocket.
How do I make a script to backup up more directories at once?

Thank you for this especially the error-to-textfile pipe. There’s a way to keep a log, too, which I saw on another page, but anyway I got my copy done.

Here is the command I used for this just as an example. I wanted not to rsync other partitions that were mounted, just the one with software including my brew install items.

This will show the syntax for the exclude option part, which I didn’t find intuitive at first. Storage is the second partition on the internal drive, 2TB3 is the external drive itself. I wasn’t sure whether it’d get read or not – the first try at this was doing NOTHING for a VERY long time except building a 2,000,000-file list. When I excluded the external drive it went smoothly.

sudo rsync -ahP –exclude=/Volumes/Storage –exclude=/Volumes/2TB3 / /Volumes/2TB3/Backup\ from\ Jeremys\ Macbook\ Pro 2> ~/Desktop/rsyncErrors.txt

Note the dashes above are two “-” characters in a row: the blog software displays as a single em dash. Let me try again.

sudo rsync -ahP –exclude=/Volumes/Storage –exclude=/Volumes/2TB3 / /Volumes/2TB3/Backup\ from\ Jeremys\ Macbook\ Pro 2> ~/Desktop/rsyncErrors.txt

How would this work using the new Google Drive Desktop app (circa Aug, 2021) while using as “Streaming” with no local storage in the Google Drive folder?

That is a really good question and I have no idea if it would work.
I don’t know if rsync would see the files as being there if they haven’t been synced to the device..

If you do work it out, comment back 🙂

Thanks for this. I found that using this command copied my source Documents folder INSIDE the destination Documents folder on my other Mac. This is not what I wanted.
I wanted to copy the CONTENTS of the source Documents folder to the destination Documents folder. To do this I had to add a backslash / at the end of the source folder path like this:
“sudo rsync -ahP / 2> ~/Desktop/rSyncErrors.txt”
Then it copied perfectly and I had a mirror image of my source Documents folder.

Thanks for this. I copied a large photo folder from an external drive on my daily-use Mac to the hard drive on an older Mac mini that I use for back-ups. The initial copy went perfectly. If I understand correctly, I just run the same Terminal command again to get an incremental update of the folder, correct? Is there a way to program that command so it runs once a day or once a week? I’m editing photos in that folder using Mac Photos, and want to back up my work. Because the photos are on an external drive, I can’t use Time Machine for that. Thanks.

Yep, running the command again will do an incremental backup.
I believe you can schedule things using Automator?

Also bonus points – You can backup external drives with time machine – https://www.macworld.com/article/229391/how-to-make-sure-time-machine-backs-up-external-drives.html

Thanks 🙂 Ducky

Thanks for your very quick reply. I tried the “bonus points” trick you suggested, but it didn’t work because the external drive stayed greyed out the whole time. I think that is because the external drive is in a different file format than the internal drive. I am going to purchase a new SSD to use as the source, and format it the same as the internal. Will report back results when completed. Thanks again. D.

Thanks for the blog – really helpful!

I’m using the command in terminal on a mac but looking to find out time remaining and current progress. I can find commands to do this but it doesn’t seem to work, anyone know of any that I can use within this set of commands to see this? I feel blind when I press enter as I’m just waiting for it to end. BTW I’m copying over 85TB in 3TB quantities from external drives to external drives.

Thanks

The way rsync goes it doesn’t calculate the full file count before it starts copying, so it doesn’t know how long it’s actually going to take.
See here for some options? https://www.cyberciti.biz/faq/show-progress-during-file-transfer/

I have not been able to get the -delete (or –delete) option to work on my Mac. I’m really interested in having the synced backup files match what is in the send directory and if a file is no longer in the send directory I want it removed from the backup destination..

As is rsync copies all of the new files to the destination directory. That part works fine.

Any updates on the -delete switch? I’m interested in having a mirror of the source drive as well, additions and deletions included.

For the delete-option you need to write “–delete”. This worked for me.

I just realized one can hardly read the essential detail of my last comment: Note, that you have to use 2 times the minus (“-“) in front of delete.

Dan Cormack

Hi!
I stumbled upon this looking for the rsync command arguments to copy all of one drive to an external drive. Your instructions have an error which I figured out after rsync started and I was not seeing the updates in the terminal window. The terminal window images in the titel graphic plus step 1 and step 5 show rsyncy -ahp (note the lower case p). I was entering that instead of the upper case p. I know, the instructions show the upper case p but my eyes jumped to the images when I was entering in my commands for some reason and that’s what my brain locked onto. It’s a good idea to update the images for accuracy.
Thank you once again for the helpful page!

Hi Duck. Can I use rsync to backup everything in my external hard drive to Google Drive? If yes, is the step-by-step to be the same?
I’m on MacBook Pro, by the way.
Thanking you in advance.

-Eve, Malaysia.

Hey – I’m not sure rsync is the right tool for that…
There’s a tool called rclone that apparently does it, I haven’t used it before, but it looks alright! https://rclone.org/

Itsa Me Moriah

Just rsync the home folder to your Google drive folder.

Keep in mind that is not everything on the computer. There can be things stored elsewhere ie Applications and items in the /usr folder for instance.

You can also use Carbon Copy Cloner which is a fantastic tool!!!

Hi there.

If Imn using Rsync on two external drives. One is a working drive which contains the folder “Working” and I want to sync the contetns of that onto my larger external HDD every time I finsih a few jobs. How do I sync the contents of “working” to my others drives folder called “2023” without creating a copy of “Working” inside the destination?

Was doing some web searching for using rsync on a MacOS (Sonoma) M1 and found this link. Worked as it says. Excellent. Thanks eh!

Woah, how have I not known about this until now?!
I have been using Macs for 15 years, and I thought I was pretty competent but this method is incredible. You have just saved me literally hours, PLUS if it doesn’t work properly, I can just look back through the terminal or that txt file and figure out what went wrong. This is a life-changer for me!

Thanks!

Hi Duk!
Thank you for the great post.
I’ve got a few questions regarding it.
I try to sync around 1,7 TB of MP3 files. When I use the command including the log file the terminal doesn’t show anything anymore but the logfile does. Is this normal?
I would love to be able to see the overall progress – otherwise I’m afraid to shut the process accicently off.
Additionally it seems to be incredibly slow. A “fast” transfer is about 38.93MB/s.
Everything is connected with Gbit Ethernet.
The command I used is this:
rsync -ahP –delete ‘/Volumes/myMedia 1/Discothek/Archiv/’ /Volumes/Music > /Volumes/myMedia\ > /SyncInfo/ArchiveSyncLog.txt

When the command is fine and the speed too I’d like to use Automator to create a workflow which allows me to execute the command like an app.

Thank you!

When you use a pipe like “> logfile.txt”, it will hide the output from the terminal.
You can watch it from another terminal window by using the command: tail -f /SyncInfo/ArchiveSyncLog.txt
(Tail will show the last few lines from the file, tail -f will keep it open and show any extra lines added while it’s running. Ctrl-C to stop it)

Not sure why you’ve got two “>” in your command there. It should be: rsync -ahP –delete [source] [destination] > logfile.txt
Another way to log it is to add in –log-file=log.txt

As for the speed – a few things will do that – Hard drive formats like Fat32/exFAT tend to be a bit slower at copying a boat load of smallish files, if I’m backing up a lot of tiny files (looking at you Photos library), I will either zip it up before I copy it to a network drive, or copy it to an afps/hfs formatted external drive.
That being said 40MB/s on gigabit is OK (I get ~110MiB/s to my NAS when copying big files)

Hope my answers helped 🙂

Ducky

The two redirects (>>) will append to the output file. I do that when logging script errors, but don’t forget about it because that log file could grow quite large quickly.

Leave a Reply