Hey Nils,

Nils Goroll wrote:
but in cases where you're powering down a laptop overnight,
you don't want to just take a load of snapshots after you power on for
every missed cron job, you just want one

This is precisely what the at solution is doing: As there is only one
at job for each zfs snapshot SMF at any one time, only one snapshot
is taken for every SMF when the machine powers up - which IS what
you want : When you say daily, you want it taken daily (if possible).

Ok, from talking to the desktop guys, they're looking for exactly this functionality as well, and I agree it'd be useful.

So, I've got a pretty basic solution:

Every time the service starts, we check for the existence of a snapshot that was taken under the current schedule that's no more than <frequency> <interval>s old - if one doesn't exist, then we take a snapshot under the policy set down by that instance.

So, in the case of daily snapshots, where a user shuts down a machine at 23:59, missing the cron job firing, as soon as the service starts again (probably when the machine reboots) it checks for a snapshot no older than 1 day in the past, and takes a snapshot if the last snapshot was (say) 24hrs 1min ago. The same would apply for monthly, weekly, every-3-days, etc.

But please do consider that some people (admins !) DO want to specify these
things, I believe you should also keep an eye on datacentre administrators, not
just "home users".

Hard to please everyone! If you felt like it, it'd be great to get the "offset" property working - that'd make the use of cron a lot more flexible for admins I think.

This is not what I (personally) want. I want to be able to specify
things like daily and still get snapshots taken even if the machine
is down for regular intervals.

Would the conditional-snapshot-on-start-method solution work for you? I know it requires a service start for it to work, but in the case of a snapshot failing for any reason, the service would drop to maintenance, and you'd be restarting the service anyway: so good for both laptop users and sysadmins I hope?

As for the other changes you suggested, I've already put some slightly
better svcprop caching code in, but just not your implementation
( something about the block comment:) ...

I like to be honest... ;-) Hardly any shell code is portable, but I
was somehow expecting you to step over this thing... I'll have a
look at your solution when it's out.

I've attached some sample code - see what you think. It just takes the smf properties and converts them into environment variables, so we'd only ever call svcprop once.

can roles run cron jobs ?),

No. You need a user who can take on the role.

Darn, back to the drawing board.

Thanks again, and keep up the good work (and please think again about
the at-vanteges ;-)

No worries!

        cheers,
                                tim
#!/bin/ksh
function get_pair {
        NAME=$1
        shift 2
        echo ${NAME}=\"[EMAIL PROTECTED]"
        echo export $NAME
}

function foo {
# Create a list of strings we can iterate over to
# set environment variables. 

IFS='
'
SMF_PROPS="$(svcprop -t -p zfs frequent  |\
            sed -e 's#zfs/fs-name#zfs/fs_name#g' \
        -e 's#zfs/backup-lock#zfs/backup_lock#g' \
        -e 's#zfs/snapshot-children#zfs/snapshot_children#g' \
        -e 's#zfs/backup-save-cmd#zfs/backup_save_cmd#g' \
        -e 's#zfs/##g' -e 's/$/,/g')"
IFS=,
for line in $SMF_PROPS ; do
        IFS='   
'
        eval $(get_pair $line)
done
}

foo
echo $backup_lock
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to