Giter VIP home page Giter VIP logo

Comments (3)

graudeejs avatar graudeejs commented on July 23, 2024

You must specify exact prefix.
in your case this is -p 'hourly-'
Note the quotes.

I see there is a bug with -D switch, that prevents deleting snapshots with prefix.
However -d flag works fine

The regexp is fine. Here's the proof:
echo "test" | grep -E -e '^t()?est$'

BTW, you shouldn't use -D flags to delete snapshots (it ignores TTL)
You should use -d flag instead.

Hope to fix this bug when I have time...
If you got patches, feel free to for and request pull.

from zfsnap.

sean- avatar sean- commented on July 23, 2024

You must specify exact prefix.
in your case this is -p 'hourly-'
Note the quotes.

Quotes shouldn't be required, there's nothing to escape for the shell.

I see there is a bug with -D switch, that prevents deleting snapshots with prefix.
However -d flag works fine

The regexp is fine. Here's the proof:
echo "test" | grep -E -e '^t()?est$'

The regexp is valid, but it wasn't ever matching. Imagine the input:

zfSnap -D tank/usr/home

I want to delete all snapshots on tank/usr/home. This will fail:

echo tank/usr/home@hourly-2012-10-03_11.04.00--3d | grep -E -e '^(|tank/usr/home)@()?-20[0-9][0-9]-[01][0-9]-[0-3][0-9]_[0-2][0-9].[0-5][0-9].[0-5][0-9]--([0-9]+y)?([0-9]+m)?([0-9]+w)?([0-9]+d)?([0-9]+h)?([0-9]+M)?([0-9]+[s]?)?$'

In the event of an empty prefix, the prefix regexp should default to '[^-]+' which would result in:

echo tank/usr/home@hourly-2012-10-03_11.04.00--3d | grep -E -e '^(|tank/usr/home)@([^-]+)?-20[0-9][0-9]-[01][0-9]-[0-3][0-9]_[0-2][0-9].[0-5][0-9].[0-5][0-9]--([0-9]+y)?([0-9]+m)?([0-9]+w)?([0-9]+d)?([0-9]+h)?([0-9]+M)?([0-9]+[s]?)?$'

Which works.

BTW, you shouldn't use -D flags to delete snapshots (it ignores TTL)
You should use -d flag instead.

Using -D was correct in this situation, the user was doing something to the effect of:

while 1
cat old > new
cat new > old
end

:~]

Hope to fix this bug when I have time...
If you got patches, feel free to for and request pull.

Aye. I haven't tested this yet, but I was thinking about something like:

diff --git a/zfSnap.sh b/zfSnap.sh
index 54318bc..d12e9b8 100755
--- a/zfSnap.sh
+++ b/zfSnap.sh
@@ -370,7 +370,10 @@ fi

delete all snap

if [ "$delete_specific_snapshots" != '' ]; then
if [ "$delete_specific_fs_snapshots" != '' ]; then

  •           rm_snapshots=`$zfs_cmd list -H -o name -t snapshot | grep -E -e "^($(echo "$delete_specific_fs_snapshots" | tr ' ' '|
    
  •           if [ -z "$prefixes" ]; then
    
  •                   prefixes='[^-]+'
    
  •           fi
    
  •           rm_snapshots=`$zfs_cmd list -H -o name -t snapshot | grep -E -e "^($(echo "$delete_specific_fs_snapshots" | tr ' ' '|
            for i in $rm_snapshots; do
                    rm_zfs_snapshot $i
            done
    

Which would let you do:

zfSnap -D tank/usr/home
zfSnap -p hourly -D tank/usr/home
zfSnap -p 'hourly|daily' -D tank/usr/home

? I think calling it a prefix is a bit misleading since it's really the frequency at which a particular snapshot is taken. Anyway, I think that's the easiest. I could change , to |, too. Anyway, LMK if that works for you and I can submit a formal pull request. -sc

Sean Chittenden
[email protected]

from zfsnap.

graudeejs avatar graudeejs commented on July 23, 2024

Instead of "hourly-" it could have been "whenever-possible-".

from zfsnap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.