FreeBSD Bugzilla – Attachment 150908 Details for
Bug 196228
[patch] sysutils/zfs-periodic deleting snapshots fails
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
scanning/deleting datasets for old snpahsots instead of pools
zfs-periodic_zfs-snapshot.patch (text/plain), 3.42 KB, created by
Harald Schmalzbauer
on 2014-12-23 14:10:24 UTC
(
hide
)
Description:
scanning/deleting datasets for old snpahsots instead of pools
Filename:
MIME Type:
Creator:
Harald Schmalzbauer
Created:
2014-12-23 14:10:24 UTC
Size:
3.42 KB
patch
obsolete
>--- bin/zfs-snapshot 2014-07-22 19:14:43.000000000 +0200 >+++ bin/zfs-snapshot 2014-12-23 14:55:56.000000000 +0100 >@@ -60,51 +60,62 @@ > type=$3 > skip=$4 > >- # create the regex matching the type of snapshots we're currently working >- # on >- case "$type" in >- hourly) >- # hourly-2009-01-01-00 >- regex="^$pool@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]$" >- ;; >- daily) >- # daily-2009-01-01 >- regex="^$pool@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$" >- ;; >- weekly) >- # weekly-2009-01 >- regex="^$pool@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]" >- ;; >- monthly) >- # monthly-2009-01 >- regex="^$pool@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]" >- ;; >- *) >- echo "unknown snapshot type: $type" >- exit 1 >- esac > > create_snapshot $pool $type >+ clean_snapshots $pool $type >+} >+ >+clean_snapshots() >+{ >+ pool=$1 > >- # get a list of all of the snapshots of this type sorted alpha, which >- # effectively is increasing date/time >- # (using sort as zfs's sort seems to have bugs) >- snapshots=`zfs list -H -o name -t snapshot | sort | grep $regex` >- # count them >- count=`echo $snapshots | wc -w` >- if [ $count -ge 0 ]; then >- # how many items should we delete >- delete=`expr $count - $keep` >- count=0 >- # walk through the snapshots, deleting them until we've trimmed deleted >- for snapshot in $snapshots; do >- if [ $count -ge $delete ]; then >- break >- fi >- delete_snapshot $snapshot >- count=`expr $count + 1` >- done >- fi >+ # loop through datasets, do look for number of snapshots each >+ for dataset in $datasets; do >+ >+ # create the regex matching the type of snapshots we're currently working >+ # on >+ case "$type" in >+ hourly) >+ # hourly-2009-01-01-00 >+ regex="^$dataset@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]$" >+ ;; >+ daily) >+ # daily-2009-01-01 >+ regex="^$dataset@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$" >+ ;; >+ weekly) >+ # weekly-2009-01 >+ regex="^$dataset@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]" >+ ;; >+ monthly) >+ # monthly-2009-01 >+ regex="^$dataset@$type-[0-9][0-9][0-9][0-9]-[0-9][0-9]" >+ ;; >+ *) >+ echo "unknown snapshot type: $type" >+ exit 1 >+ esac >+ >+ # get a list of all of the snapshots of this type sorted alpha, which >+ # effectively is increasing date/time >+ # (using sort as zfs's sort seems to have bugs) >+ snapshots=`zfs list -H -o name -t snapshot | sort | grep $regex` >+ # count them >+ count=`echo $snapshots | wc -w` >+ if [ $count -ge 0 ]; then >+ # how many items should we delete >+ delete=`expr $count - $keep` >+ count=0 >+ # walk through the snapshots, deleting them until we've trimmed deleted >+ for snapshot in $snapshots; do >+ if [ $count -ge $delete ]; then >+ break >+ fi >+ delete_snapshot $snapshot >+ count=`expr $count + 1` >+ done >+ fi >+ done > } > > # take snapshots of type, for pools, keeping keep old ones,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 196228
:
150908
|
173896
|
174114
|
223625
|
223627
|
223628