I am trying to script checking a network volume and comparing it against with a local copy to see if there is enough space to copy the files.
The files will copied using rsync and I use the following to get the available space
VAR1=`du -sh /Volumes/networkshare/user`
VAR2=`du -sh /Users/user1/`
If I was to do an
if [ $VAR1 -lt $VAR2 ]
then echo "Enough Space"
fi
Then that might work for the initial backup but this will run once a day using rsync and therefore wont be a good check for available space as only new files and changed files will be copied up. Is there a better way to do this sort of check?
Edit: The share has a size limit of 50gb but I am unsure how I could use this if rsync isnt copying everything
Thanks
There is a way to get a feel for the total size of the new or changed files that will be sent. However, this is before
rsync
computes the incremental part of each file that will be transferred if it already exists on the destination host. There is no way to obtain the incremental size thatrsync
will actually transfer to update the remote location. This code can be used as a one-liner albeit a long one liner. Take a look and see if knowing the size of the new/changed files helps you in your calculation.Note: the files in the
rsync
command are just for example:example:
This could be used as an outside approximation of the maximum space the new/changed files would add to the remote storage.