Rsync Wrapper a scriptable Cocoa application for the rsync utility

Rsync Wrapper is a simple Objective-C wrapper for the rsync utility which provides AppleScript support and the ability to display a progress bar and transfer statistics.

rsync is an open source utility that provides fast incremental file transfer.

The rsync version that comes with Mac OS X is quite old (2.6.9).
Rsync Wrapper uses the most recent stable version (3.1.0) including the following Mac OS X related patches:

compression.diff
crtimes.diff
fileflags.diff

The AppleScript dictionary contains one command, the source and destination references can be POSIX paths, HFS paths or alias specifiers

The rsync command returns a record

This is a code example, the arguments must be passed as a list of strings, an explicit quotation is not necessary


tell application "Rsync Wrapper"
	activate
	set {exit code:exitCode, error message:errorMessage, items transferred:filesCopied, statistics:stats} to rsync from source "/path/to/source" to destination "/path/to/destination" arguments {"-au", "--exclude=.DS_Store"}
	
end tell
if exitCode is not 0 then
	display dialog errorMessage
else
	display dialog stats
end if

Notes:

¢ To avoid interferences while running rsync the following flags are ignored: -v, --verbose, --progress, --stats, --dry-run.
¢ Any trailing slashes in the source and destination paths are ignored too.
¢ The rsync AppleScript command works synchronously, the next code line is executed after completion.
¢ I haven’t tested a real large file transfer, maybe a timeout block is needed
¨¢ Rsync Wrapper quits automatically after task completion.

The application is code-signed, minimum system requirements: 10.7 Lion

Download: Rsync Wrapper.zip

The software is distributed “as is”, without any warranty nor responsibility for potentially lost data

Any chance you can post the source code to your wrapper? I’d like to take a look at it and see how you wrote it in case in the future I’d like to write a wrapper for some other command.

The code calls rsync via NSTask very similar to the code in this thread, but written in Objective-C
MacScripter / Multi-task rsync command within ASOC app.

To perform rsync synchronously in the AppleScript environment the NSScriptCommand subclass is suspended and resumed after completion

Stefan,
im on 10.7.5 and rsync crashes all the time if i click your rsync package.

[code]Crashed Thread: Unknown

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00007fff5fc01028

Backtrace not available[/code]
However, i see a rsync Wrapper in ‘Activity Monitor’. Do i need some patches or additional bins ?

sorry, I can’t test it on Lion, but actually it’s supposed to be compatible with 10.7

Hi. I just found this post and downloaded this very useful app; thank you for sharing.

I have encountered a problem that I’m hoping will be an easy fix. When I go to use the Rsync Wrapper with this applescript:

tell application "FileMaker Pro Advanced"
	set sourceFolder to cell "Paths::Path to job folder" of current record & "/RAW"
	set targetFolder to cell "Paths::Path to archive folder" of current record
end tell

tell application "Rsync Wrapper"
	activate
	set {exit code:exitCode, error message:errorMessage, items transferred:filesCopied, statistics:stats} to rsync from source sourceFolder to destination targetFolder arguments {"-a"}
	
end tell

This works as expected; a folder named RAW is created at the target and the files are copied to it.

However when I use the code below with the trailing “/” in the path, my understanding is that only the files should be copied, with no RAW folder created in the target.

Instead, the behavior is the same; a a folder named RAW is created at the target and the files are copied to it.:


tell application "FileMaker Pro Advanced"
	set sourceFolder to cell "Paths::Path to job folder" of current record & "/RAW/"
	set targetFolder to cell "Paths::Path to archive folder" of current record
end tell

tell application "Rsync Wrapper"
	activate
	set {exit code:exitCode, error message:errorMessage, items transferred:filesCopied, statistics:stats} to rsync from source sourceFolder to destination targetFolder arguments {"-a"}
	
end tell

I would appreciate any help in getting this to work so that no RAW folder is created in the target. Thanks!!

Eric

The reason for this behavior is, that the path method of NSURL “ it strips the path portion of a valid URL “ returns always a file path without trailing slash

I changed the code to preserve the trailing slash, same link.

Thank you. That fixes my issue.

The change created a small bug perhaps…in the new version you just posted, the progress meter no longer displays the filename being copied.

Your help is very appreciated.

Eric

That was very tricky to figure out the proper algorithm to filter the line which includes the filename.
In the non-trailing slash version the line starts always with the enclosing folder name.

But eventually I got it.

Same link.

Working perfectly for me now. Thank you.

If you are adding any more features to Rsync Wrapper, one that I would suggest would be to display the size of the file that is currently being transferred after it’s name. This could serve as an additional reminder to the user to be patient when a large file is transferring.

Thanks again,

Eric

Thanks for the suggestion. It’s implemented. Same link

Thank you for creating this useful tool.

Eric

Hi Stefan,

I have been using rsync wrapper for several months now and I find it extremely helpful.

I don’t know if this a tool that you are interested in developing further, but I have encountered two issues that if resolved would make this even more awesome :slight_smile:

~ If the user needs to abort a transfer for any reason there is no easy way to do that.

~ If the user starts a second simultaneous transfer using rsync wrapper, it is unclear what happens. The first dialog is replaced by the second dialog…but the user can’t tell if the first transfer was interrupted or if it is ongoing in the background. It would be ideal if a second window were to open instead.

Even if there’s no time to work on any of that, this is still a very useful tool.

thanks!

Eric

Hello Stefan,
few years later Rsync Wrapper is still a gem. Being able to add progress bar to rsync related Applescript is a real gift, thank you very much for it!
Though i am struggling to make it work when doing backups to NAS : timeout gets on the way.
Progress bar just shows forever “preparing…”, script gets stuck (beach ball), no synchronized backup gets done.
Sorry i am just in first year Applescript Kindergarten and do not really know how to fix this problem when a server connection is involved (server volume is, of course, mounted; it works perfectly between hard disks, internal or external).
Thank you very much in advance for your help*.
Philippe.
P.-S.
Systems in use : the latest versions of El Capitan & Sierra
(*) Please let me know if donation required.

Model: iMac 2011
AppleScript: 2.5
Browser: Safari 603.2.5
Operating System: Mac OS X (10.10)

I don’t have a network volume so I can’t test anything.

The workflow of Rsync Wrapper performs first a dry run to get the statistics before doing the actual copy job

What happens when you run rsync in Terminal.app with the following syntax

[format]rsync --stats --dry-run /path/to/source /path/to/destination[/format]

Thanks a lot Stefan for your quick feedback.

Result ↓

skipping directory /Users/(MyAccount)/Desktop/source

Number of files: 0
Number of files transferred: 0
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 5
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 21
Total bytes received: 20

sent 21 bytes received 20 bytes 82.00 bytes/sec
total size is 0 speedup is 0.00

I previously forgot to specify that Rsync Wrapper works fine on the network volume if source folder weights only few GB.
Trouble starts with more than, let say, roughly 10~20 GB or so…

Please let me know if more tests or information needed.
Thank you in advance for your help, deeply appreciated.

Stefan,
any hope for a soon improvement of this very fine rsync wrapper except when used with a network volume or USB external hard disk (same problem)?
If not, I’ll try to modify my apple script for a one by one folder backup sync to involve less data at once.
Thanks in advance for clarifying this.
Best regards,
Philippe.
(again, if donation (quickly) required, please let me know. Or should I know… ;-)).

Unfortunately there is no hope at the moment. sorry.

Thanks for your quick reply, understood.
Enjoy your summer!