Move prev deletion below and guarantee data flush before marking backup as finished
This commit is contained in:
parent
2481728f4f
commit
66a463edd6
@ -2,6 +2,9 @@
|
|||||||
#
|
#
|
||||||
# BTRFS delta snapshots with incomplete send handling
|
# BTRFS delta snapshots with incomplete send handling
|
||||||
# CC0 ~caskd
|
# CC0 ~caskd
|
||||||
|
#
|
||||||
|
# Note that this script currently has no locking mechanism
|
||||||
|
# This is left as a requirement to be guaranteed from the outside
|
||||||
|
|
||||||
: ${SRC:?'Source not defined'}
|
: ${SRC:?'Source not defined'}
|
||||||
: ${SNAPDIR:?'Snapdir not defined'}
|
: ${SNAPDIR:?'Snapdir not defined'}
|
||||||
@ -37,6 +40,7 @@ delta() {
|
|||||||
[ -e "$DESTPATH.tmp" ] && rm -v "$DESTPATH.tmp"
|
[ -e "$DESTPATH.tmp" ] && rm -v "$DESTPATH.tmp"
|
||||||
|
|
||||||
if btrfs -v send --compressed-data -p "$CUR" "$TMP" | compress > "$DESTPATH.tmp"; then
|
if btrfs -v send --compressed-data -p "$CUR" "$TMP" | compress > "$DESTPATH.tmp"; then
|
||||||
|
sync "$DESTPATH.tmp"
|
||||||
mv -v "$DESTPATH.tmp" "$DESTPATH"
|
mv -v "$DESTPATH.tmp" "$DESTPATH"
|
||||||
ln -sv "../$TS_PARENT" "$DEST/$TS_CURRENT/$PARENTNAME"
|
ln -sv "../$TS_PARENT" "$DEST/$TS_CURRENT/$PARENTNAME"
|
||||||
fi
|
fi
|
||||||
@ -51,6 +55,7 @@ full() {
|
|||||||
[ -e "$DESTPATH.tmp" ] && rm -v "$DESTPATH.tmp"
|
[ -e "$DESTPATH.tmp" ] && rm -v "$DESTPATH.tmp"
|
||||||
|
|
||||||
if btrfs -v send --compressed-data "$TMP" | compress > "$DESTPATH.tmp"; then
|
if btrfs -v send --compressed-data "$TMP" | compress > "$DESTPATH.tmp"; then
|
||||||
|
sync "$DESTPATH.tmp"
|
||||||
mv -v "$DESTPATH.tmp" "$DESTPATH"
|
mv -v "$DESTPATH.tmp" "$DESTPATH"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -65,14 +70,13 @@ symdel() {
|
|||||||
mkdir -vp "$SNAPPATH" >&2
|
mkdir -vp "$SNAPPATH" >&2
|
||||||
|
|
||||||
symdel "$TMP"
|
symdel "$TMP"
|
||||||
symdel "$PREV"
|
|
||||||
|
|
||||||
ln -sv "$CDATE" "$TMP" >&2
|
ln -sv "$CDATE" "$TMP" >&2
|
||||||
btrfs subvolume snapshot -r "$SNAPSRC" "$SNAPDEST" >&2
|
btrfs subvolume snapshot -r "$SNAPSRC" "$SNAPDEST" >&2
|
||||||
|
|
||||||
delta || full || return 1
|
delta || full || return 1
|
||||||
|
|
||||||
# Mark snapshot transmission as complete
|
# Mark snapshot transmission as complete
|
||||||
|
symdel "$PREV"
|
||||||
[ -L "$CUR" ] && \
|
[ -L "$CUR" ] && \
|
||||||
mv -v "$CUR" "$PREV" >&2
|
mv -v "$CUR" "$PREV" >&2
|
||||||
mv -v "$TMP" "$CUR" >&2
|
mv -v "$TMP" "$CUR" >&2
|
||||||
|
Loading…
Reference in New Issue
Block a user