I’m trying to calculate the size of an rsync backup before executing it:
du -hs -- $(rsync -avn --exclude --delete $source $target | grep / | grep -v " bytes/sec" | grep -v "deleting " | cut -d "/" -f2- | awk 'NF' | awk '$0="$source/"$0')
It fails with error: Argument list too long.
As far as I understand the command is bigger then the ARG_MAX limit.
I also tried xargs, but it fails too:
rsync -avn --exclude --delete $source $target | grep / | grep -v " bytes/sec" | grep -v "deleting " | cut -d "/" -f2- | awk 'NF' | awk '$0="$source/"$0'| xargs -P4 -n9999999 du -hs -- 2>/dev/null | tail -1 | awk {'print $1'}
(Ends with output 23GB but it is far more)
My question is: Is there another way to pre-calculate the size of an rsync-backup?
Thanks