[OpenIndiana-discuss] Finding the "last" snapshot for a zfs volume

Discussion list for OpenIndiana openindiana-discuss at openindiana.org
Mon May 12 18:03:35 UTC 2014


I have a backup script that locates the snapshot name of the last snapshot
on the single filesystem like so:

zfs list -H -d 1 -o name -S creation -t snapshot "$target" | head -n 1 |
cut -f2 -d@

(actually, I have another grep in the chain that only looks for backup
snapshots)

The "$target" points it at a single filesystem, -S creation means sort by
creation time, -H means don't print the column headers, -d 1 (depth 1) and
-t snapshot combine to list only the snapshots of that filesystem.  The
head gets the first, being most recent, and the cut strips the filesystem
name, leaving only the snapshot name.

Tim



On Mon, May 12, 2014 at 6:48 AM, Discussion list for OpenIndiana <
openindiana-discuss at openindiana.org> wrote:

> Most of my systems I do "zfs list -t snapshot > file" then grep that file
> of each of the filesystems I am interested in.
>
> John
>
> -----Original Message-----
> From: Discussion list for OpenIndiana [mailto:
> openindiana-discuss at openindiana.org]
> Sent: 12 May 2014 12:20
> To: Discussion list for OpenIndiana
> Subject: [OpenIndiana-discuss] Finding the "last" snapshot for a zfs volume
>
> On our backup servers I have a "backup-check" script that checks to see
> what the last snapshot for a particular volume is (and compares it with the
> current date)
>
> df -F zfs -h |grep $mypool | nawk '{system("zfs list -t snapshot -r "$1"
> \| tail -1")}' | egrep -v "$yesterday|no datasets"
>
> okay, it's messy, but it should find the last snapshot for each zfs slice
> within a pool.
>
> However with the number of pools on the server increasing, and the number
> of snapshots getting bigger every day, I was wondering if there is an
> easier way of getting the latest snapshot than "zfs list -t snapshot -r
> pool/snapshot | tail -1"
>
> Any ideas would be helpful.
>
> Jon
> _______________________________________________
> OpenIndiana-discuss mailing list
> OpenIndiana-discuss at openindiana.org
> http://openindiana.org/mailman/listinfo/openindiana-discuss
>
> _______________________________________________________________________
>
> The contents of this e-mail and any attachment(s) are strictly
> confidential and are solely for the person(s) at the e-mail address(es)
> above. If you are not an addressee, you may not disclose, distribute, copy
> or use this e-mail, and we request that you send an e-mail to
> admin at stirling-dynamics.com and delete this e-mail.  Stirling Dynamics
> Ltd. accepts no legal liability for the contents of this e-mail including
> any errors, interception or interference, as internet communications are
> not secure.  Any views or opinions presented are solely those of the author
> and do not necessarily represent those of Stirling Dynamics Ltd. Registered
> In England No. 2092114 Registered Office: 26 Regent Street, Clifton,
> Bristol. BS8 4HG
> VAT no. GB 464 6551 29
> _______________________________________________________________________
>
> This e-mail has been scanned for all viruses MessageLabs.
>
> _______________________________________________
> OpenIndiana-discuss mailing list
> OpenIndiana-discuss at openindiana.org
> http://openindiana.org/mailman/listinfo/openindiana-discuss
>


More information about the openindiana-discuss mailing list