Fix replication again.
This commit is contained in:
@@ -124,23 +124,20 @@ in
|
||||
# Find previous snapshot on sender
|
||||
PREV_LOCAL=$(ls -t /persist/services@* 2>/dev/null | grep -v "^$SNAPSHOT_PATH$" | head -1 || true)
|
||||
|
||||
# Try incremental send if we have a parent, fall back to full send if parent missing on receiver
|
||||
# Try incremental send if we have a parent, fall back to full send if it fails
|
||||
if [ -n "$PREV_LOCAL" ]; then
|
||||
echo "Attempting incremental send from $(basename $PREV_LOCAL) to ${standby}"
|
||||
|
||||
# Capture both stdout and stderr to check for parent missing error
|
||||
if OUTPUT=$(btrfs send -p "$PREV_LOCAL" "$SNAPSHOT_PATH" 2>&1 | \
|
||||
ssh -i "$SSH_KEY" -o StrictHostKeyChecking=accept-new root@${standby} \
|
||||
"btrfs receive /persist/services-standby" 2>&1); then
|
||||
# Try incremental send, if it fails (e.g., parent missing on receiver), fall back to full
|
||||
if btrfs send -p "$PREV_LOCAL" "$SNAPSHOT_PATH" | \
|
||||
ssh -i "$SSH_KEY" -o StrictHostKeyChecking=accept-new root@${standby} \
|
||||
"btrfs receive /persist/services-standby"; then
|
||||
echo "Incremental send completed successfully"
|
||||
elif echo "$OUTPUT" | grep -q "cannot find parent subvolume"; then
|
||||
echo "Parent snapshot not found on receiver, falling back to full send"
|
||||
else
|
||||
echo "Incremental send failed (likely missing parent on receiver), falling back to full send"
|
||||
btrfs send "$SNAPSHOT_PATH" | \
|
||||
ssh -i "$SSH_KEY" -o StrictHostKeyChecking=accept-new root@${standby} \
|
||||
"btrfs receive /persist/services-standby"
|
||||
else
|
||||
echo "ERROR: Incremental send failed: $OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# First snapshot, do full send
|
||||
|
||||
Reference in New Issue
Block a user