this script is a part of a linux live-cd installer.
rsync -aq / /TARGET/ exclude-from=exclude.list &>> errors.log
i would like to report back to a gui the progress. the gui (gtkdialog) responds to any number 0-100 (echo 1; echo 2; etc...)
rsync -n (dry run) takes too long in this case.
i would like to run...
filesystem_size=`(get directory size) / exclude=exclude.list`
rsync -aq / /TARGET/ exclude-from=exclude.list &
while [ rsync is running ]; do
(check size) /TARGET/
compare to $filesystem_size
echo $number (based on the difference of sizes)
done
please help with getting directory size with multiple excludes, while loop for while rsync is running, echo number (0-100) based on the difference of the two sizes.
answering any of the above is a great help, thank you.
EDIT: ADDING COMPLETED RSYNC PROGRESS OUTPUT (there seems to be enough people looking for this) with help from Olivier Dulac i made this work.
size_source=`du -bs --exclude-from=/path/to/exclude.list /source/ | sed "s/[^0-9]*//g"`
size_target=`du -bs /target/ | sed "s/[^0-9]*//g"`
rsync -aq /source/ /target/ --exclude-from=/path/to/exclude.list &
while [[ `jobs | grep "rsync"` ]]; do
size_target_new=`du -bs /TARGET/ | sed "s/[^0-9]*//g"`
size_progress=`expr $size_target_new - $size_target`
expr 100 \* $size_progress / $size_source
sleep 10
done
this will print % done to command line, only useful for large transfers.
if rsync overwrites files it will throw off the progress (show less progress than actually done)
exclude.list reads the same in rsync and du, BUT du always needs full path while rsync assumes exclude is inside its source. they can be the same file if copying rootfs "/" otherwise you must write full path for du ( just add /source/ to the beginning of each line in file.)