Skip to content

Commit

Permalink
xbian-storager backup: fix of error status
Browse files Browse the repository at this point in the history
- see http://forum.xbian.org/thread-4120-post-37005.html
- under strange circumstances, sporadically during the error-free backup,
  however, an error occurred by mistake and the backup was deleted again
- the return values of all programs contained in the pipe are now
  determined and logged in case of error
- cosmetical: the progress output is held at 100 when this is reached
  for the first time
  • Loading branch information
mkreisl committed May 13, 2021
1 parent c49f288 commit a8e0657
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions content/usr/local/sbin/xbian-storager
Expand Up @@ -1637,29 +1637,32 @@ do_backuphome ()
cpb () {
ar=0
while read a; do
echo "$a" | grep -q ^[0-9] && { (($a > $ar)) && ar=$a; echo "$a"; }
done | eval "$PIPECMD"
echo "$a" | grep -q ^[0-9] && { (($a > $ar)) && ar=$a || ar=100; echo "$ar"; }
done | eval "$PIPECMD" || :
}
if [ "$opt_fstype" = btrfs ]; then
btrfs sub delete "${tmp_dir}/home/@ro" 2>/dev/null
btrfs sub snap -r "${tmp_dir}/home/@" "${tmp_dir}/home/@ro" && \
( btrfs send -v "${tmp_dir}/home/@ro" | pv -i 20 -n -s $(du -sxb ${tmp_dir}/home/@ro | awk '{printf "%d", $1*1.08}') | $packcmd -1 >> "$FILE") 2>&1 | cpb
RC=$?
ps=${PIPESTATUS[*]}
btrfs sub delete "${tmp_dir}/home/@ro" && btrfs fi sync ${tmp_dir}
else
home_ds=$(zfs list -Ho name,mountpoint | grep /home$ | awk '{print $1}')
zfs destroy ${home_ds}@ro 2>/dev/null
zfs snapshot ${home_ds}@ro && \
( zfs send --props ${home_ds}@ro | pv -i 20 -n -s $(zfs list -Hpo refer,compressratio ${home_ds}@ro | awk '{printf "%d", $1*$2*0.970}') | $packcmd -1 >> "$FILE") 2>&1 | cpb
RC=$?
ps=${PIPESTATUS[*]}
zfs destroy ${home_ds}@ro
fi
set +o pipefail

if [ "$RC" -ne 0 ]; then
rm -f "$FILE"
exit 1
fi
for RC in $ps; do
if [ "$RC" -ne 0 ]; then
print_log error "error(s) happened while copying data ($ps)"
rm -f "$FILE"
exit 1
fi
done

if [ "$(dirname "$fn")" = "/xbmc-backup" -o "$fn" = "//" ]; then
if [ "$fn" = "//" ]; then
Expand Down

0 comments on commit a8e0657

Please sign in to comment.