Skip to content

Commit

Permalink
Always create snapshots
Browse files Browse the repository at this point in the history
Prior to this commit, zap would only create new snapshots for filesystem
that had changed since the last snapshot.  If there were no changes,
then the name of the most recent snapshot would be updated with the
current date.  There were problems with this logic, so just
unconditionally create the snapshot.
  • Loading branch information
Jehops committed Aug 24, 2016
1 parent 4bd4814 commit 543dbba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
8 changes: 2 additions & 6 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*** Key features
- no configuration files
- uses "namespaces" to avoid collisions with other snapshots
- creates and destroys snapshots only when it makes sense [2][3]
- creates and destroys snapshots only when it makes sense [2]
- written in POSIX sh

** Synopsis
Expand Down Expand Up @@ -80,8 +80,4 @@ SHELL=/bin/sh
[1] zap was influenced by zfSnap, which is under a BEER-WARE license.
We owe the author a beer.

[2] New snapshots are only created when a filesystem has changed since the last
snapshot. If the filesystem has not changed, then the timestamp of the newest
snapshot is updated.

[3] If the pool is in a DEGRADED state, zap will not destroy snapshots.
[2] If the pool is in a DEGRADED state, zap will not destroy snapshots.
21 changes: 3 additions & 18 deletions zap
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@
# [1] zap was influenced by zfSnap, which is under a BEER-WARE license. We owe
# the authors a beer.
#
# [2] New snapshots are only created when a filesystem has changed since the
# last snapshot. If the filesystem has not changed, then the timestamp of the
# newest snapshot is updated.
#
# [3] If the pool is in a DEGRADED state, zap will not destroy snapshots.
# [2] If the pool is in a DEGRADED state, zap will not destroy snapshots.
#

fatal () {
Expand All @@ -54,7 +50,7 @@ fatal () {
}

help () {
readonly version=0.3.0
readonly version=0.4.0

cat <<EOF
NAME
Expand Down Expand Up @@ -145,18 +141,7 @@ create () {
grep -q "FAULTED\|OFFLINE\|REMOVED\|UNAVAIL"; then
warn "zap skipped creating a snapshot for $i because of pool state!"
else
r=$(zfs list -rHo name -t snap -S name "$i" | grep "${i}${zptn}" | \
grep -e "--${ttl}" -m1)
if [ ! -z "$r" ]; then
s=$(zfs get -H -o value written "$r")
if [ "${s}" != "0" ]; then
zfs snapshot "${i}@ZAP_${date}--${ttl}"
else
zfs rename "${r}" "${i}@ZAP_${date}--${ttl}"
fi
else
zfs snapshot "${i}@ZAP_${date}--${ttl}"
fi
zfs snapshot "${i}@ZAP_${date}--${ttl}"
fi
done
}
Expand Down

0 comments on commit 543dbba

Please sign in to comment.