Hello, I have a couple of questions about using rsync scriptographically. I've looked around and can't find anything. I must be missing something obvious. I'm trying to write a script that will synchronise various local folders on a Mac OS X Workstation to an SMB mounted Windows (2003, mostly) Server where the user I'm copying as has a quota applied. I want to compare the available space I have, which I can find with: df /Volumes/$USER | grep % | awk -F'[ ] ' '{ print $4 }' Against the amount of data that rsync thinks it is going to copy. What I'm after is the most efficient way of finding out how much data rsync wants to copy, dying (relatively) gracefully should it be within X of the quota (say, 10MB or so). At the moment I can use the same rsync command I'd run to do the copy but with the -n option: rsync -a -u -z -E -r -l -n --progress /path/to/src /Volumes/path/to/dest/ | grep "total size is" | awk -F'[ ]' '{ print $4 }' to do a dry-run to grep and cut a number from rsync's output. The only thing is that this might take a while if there are very many files and potentially there are hundreds of thousands. I'd then have to go and run the same command all over again should the data fit, this time without the -n option. I also feel that my units may be rather disparate (i.e. df's output isn't the same unit sizes as rsync's). I'm sure there must be a better way than running rsync twice. On another note I'm getting an error: copyfile(.._..v6AxMh,./., COPYFILE_UNPACK) failed:13 When trying to run with -E. The consensus seems to be that it's a permissions issue (which I'll investigate later). Thoughts? Many thanks, ~W ***IMPORTANT NOTE*** As of the 1st March 2010 we have incorporated our Mac Support Services within Amsys PLC. Amsys PLC. Byron House, Lower Road, Kenley, Surrey, CR8 5NB (T) +44 (0)20 8660 7750 (F) +44 (0)20 8763 0924 (W) www.amsys.co.uk (E) info at macolytes.co.uk - Apple Authorised Service Provider (AASP) - DISCLAIMER NOTICE The information contained within this e-mail is confidential and is intended solely for the addressee. Access to this e-mail by any other party is unauthorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of Amsys PLC. Internet communications are not secure and Amsys PLC. does not accept any responsibility for the contents of this message or changes made to this message after it was sent. Please consider the environment before printing this e-mail -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20100811/e4f95ca8/attachment.html>
On Wed, 2010-08-11 at 16:07 +0100, William Hunter wrote:> I'm trying to write a script that will synchronise various local > folders on a Mac OS X Workstation to an SMB mounted Windows (2003, > mostly) Server where the user I'm copying as has a quota applied. I > want to compare the available space I have, which I can find with: > > > df /Volumes/$USER | grep % | awk -F'[ ] ' '{ print $4 }' > > > Against the amount of data that rsync thinks it is going to copy.Do I understand correctly that you are picking out the "Available" field from the df output?> What I'm after is the most efficient way of finding out how much data > rsync wants to copy, dying (relatively) gracefully should it be within > X of the quota (say, 10MB or so). > > > At the moment I can use the same rsync command I'd run to do the copy > but with the -n option: > > > rsync -a -u -z -E -r -l -n > --progress /path/to/src /Volumes/path/to/dest/ | grep "total size is" > | awk -F'[ ]' '{ print $4 }' > > > to do a dry-run to grep and cut a number from rsync's output.Are you copying to a new destination or an existing destination? If it is an existing destination, what you really want is not the total size of the source but the anticipated change in size of the destination, given that some files may have been copied already and other destination files may be subject to deletion if you use --delete. Alternatively, if the destination is the only thing on the volume, you could compare the total volume size to the source size.> The only thing is that this might take a while if there are very many > files and potentially there are hundreds of thousands. I'd then have > to go and run the same command all over again should the data fit, > this time without the -n option. I also feel that my units may be > rather disparate (i.e. df's output isn't the same unit sizes as > rsync's)."BLOCKSIZE=1 df" will give output in bytes, like the rsync "total size" field, but there is still filesystem overhead.> I'm sure there must be a better way than running rsync twice.The only possibility I can think of is to use rsync in non-incremental-recursion mode and patch it to check the quota just as it finishes building the file list.> On another note I'm getting an error: > > > copyfile(.._..v6AxMh,./., COPYFILE_UNPACK) failed:13 > > > When trying to run with -E.Upstream rsync has no such error message. If you're using the Apple-modified rsync, we don't support it here. -- Matt