Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: corrected diskspace calculation in case of docker usage #864

Merged
merged 8 commits into from
Apr 5, 2019
13 changes: 9 additions & 4 deletions bin/ncp/BACKUPS/nc-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ fail() { local ret=$?; echo "Abort..." ; rm -f "${dbbackup}" "${destfile}"; $
trap cleanup EXIT
trap fail INT TERM HUP ERR

echo "check free space..." # allow at least ~100 extra MiB
echo "check free space..." # allow at least ~500 extra MiB
mkdir -p "$destdir"
[[ "$includedata" == "yes" ]] && \
dsize=$(du -sb "$datadir" | awk '{ print $1 }')
dsize=$(du -sb "$datadir" | awk '{ print $1 }')
nsize=$(du -sb "$basedir/nextcloud" | awk '{ print $1 }')
size=$((nsize + dsize + 100*1024))
margin=$((500*1024)) # safety margin to allow additional space
if [[ "$includedata" == "yes" ]]
then
size=$((nsize + margin))
else #datadir is inside $basedir/nextcloud therefor substract
size=$((nsize - dsize + margin))
fi
free=$( df -B1 "$destdir" | tail -1 | awk '{ print $4 }' )

[ $size -ge $free ] && {
Expand Down