Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

home backup files vanish
Thank you for your donation

Thread Closed 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
home backup files vanish
28th Apr, 2021, 09:25 PM
Post: #10
Nachteule Offline
Administrator
******
Posts: 2,406
Joined: Dec 2014
Reputation: 122
RE: home backup files vanish
(27th Apr, 2021 06:13 PM)alcina Wrote:  So I think the error is coming from cpb, i.e the second exit code in the pipe as a whole. But I don't know why. /tmp/xbiancopy.log contains lots of stuff relating to successful btrfs and ends "Operation sucessfully completed!". /tmp/backuphome.log contains the lines starting with positive digits from the output of pv in the pipe as the grep implies.

This was also my first thought, but all tests I have done always lead to the same result: cpb() never terminates with an error in the xbian-storager script.
However, in a simplified test program it does give an error. But why this sometimes brings an error and sometimes not is completely unclear to me.

Terminal

kmnote5:/tmp # cat t.sh
#!/bin/bash

PIPECMD="cat > /tmp/out.log"

cpb () {
ar=0
while read a; do
echo "$a" | grep -q ^[0-9] && { (($a > $ar)) && ar=$a; echo "$a"; }
done | eval $PIPECMD || :
}

set -o pipefail

false | true | echo -e "1\n2\n3\n" | cpb

ps=${PIPESTATUS[*]}
RC=0; for i in $ps; do [ "$i" -ne 0 ] && RC=$i; done
echo $RC, $ps
kmnote5:/tmp # ./t.sh
1, 1 0 0 0

The solution seems simple, just add a ' || :' after the $PIPECMD this deletes the strange error if it occurs.

Code:
diff --git a/content/usr/local/sbin/xbian-storager b/content/usr/local/sbin/xbian-storager
index 3d462ca..98f9dda 100755
--- a/content/usr/local/sbin/xbian-storager
+++ b/content/usr/local/sbin/xbian-storager
@@ -1637,26 +1637,28 @@ 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

+       RC=0; for i in $ps; do [ "$i" -ne 0 ] && RC=$i; done
        if [ "$RC" -ne 0 ]; then
+               echo "Pipe result: $ps" | eval "$PIPECMD"
                rm -f "$FILE"
                exit 1
        fi
Find all posts by this user
« Next Oldest | Next Newest »
Thread Closed 


Messages In This Thread
home backup files vanish - alcina - 16th Apr, 2021, 02:19 AM
RE: home backup files vanish - Nachteule - 16th Apr, 2021, 11:39 PM
RE: home backup files vanish - alcina - 17th Apr, 2021, 07:16 PM
RE: home backup files vanish - Nachteule - 17th Apr, 2021, 08:26 PM
RE: home backup files vanish - alcina - 17th Apr, 2021, 11:39 PM
RE: home backup files vanish - Nachteule - 18th Apr, 2021, 12:37 AM
RE: home backup files vanish - alcina - 18th Apr, 2021, 03:33 AM
RE: home backup files vanish - Nachteule - 18th Apr, 2021, 04:14 AM
RE: home backup files vanish - alcina - 27th Apr, 2021, 06:13 PM
RE: home backup files vanish - Nachteule - 28th Apr, 2021 09:25 PM
RE: home backup files vanish - alcina - 29th Apr, 2021, 02:55 AM
RE: home backup files vanish - Nachteule - 13th May, 2021, 11:14 PM

  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 17th Jun, 2025, 01:41 AM Powered By MyBB, © 2002-2025 MyBB Group.