Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jun 2012 10:09:20 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        =?ISO-8859-1?Q?Karli_Sj=F6berg?= <Karli.Sjoberg@slu.se>
Cc:        "ports@FreeBSD.org" <ports@FreeBSD.org>, "marius@nuenneri.ch" <marius@nuenneri.ch>
Subject:   Re: RFE - FreeBSD Port: zfs-snapshot-mgmt-20090201_2
Message-ID:  <4FED54A0.7040209@FreeBSD.org>
In-Reply-To: <BB9E89F3-4E7F-4FA1-B3B4-4C54FC60F504@slu.se>
References:  <F62E9426-0A8A-4ED3-B93B-0998A392C7FE@slu.se> <4FECE6A7.1080102@FreeBSD.org> <BB9E89F3-4E7F-4FA1-B3B4-4C54FC60F504@slu.se>

next in thread | previous in thread | raw e-mail | index | archive | help
on 29/06/2012 09:39 Karli Sjöberg said the following:
> Thanks, that was fast!
> 
> # patch /usr/local/bin/zfs-snapshot-mgmt zfs-snapshot-mgmt.patch 
> Hmm...  Looks like a unified diff to me...
> The text leading up to this was:
> --------------------------
> |--- zfs-snapshot-mgmt2010-06-02 05:31:28.759931924 +0300
> |+++ zfs-snapshot-mgmt2010-06-01 01:49:46.665034414 +0300
> --------------------------
> Patching file /usr/local/bin/zfs-snapshot-mgmt using Plan A...
> patch: **** malformed patch at line 12: @name).readlines.collect.select { |item|
> item[0, @name.length + 1] == @name +
> 
> 
> OK, so that didn´t go that well. Manually editing the script to what I think you
> ment:

I should have remembered that copy+paste over email usually doesn't work very
well.  So here is the patch again:
http://people.freebsd.org/~avg/snapshot.list.diff

> /usr/local/bin/zfs-snapshot-mgmt:
> #  def snapshots(prefix)
> #    path = File.join(@mount_point, '.zfs', 'snapshot')
> #    Dir.open(path).select do |name|
> #      name[0, prefix.length] == prefix
> #    end.map { |name| SnapshotInfo.new(name, @name, prefix) }
> #  end
>     
> #    path = File.join(@mount_point, '.zfs', 'snapshot')
> #    Dir.open(path).select do |name|
>     s = IO.popen('zfs list -r -t snapshot -H -o name
> '@name).readlines.collect.select { |item| item[0, @name.length + 1] == @name '@'
> }.map { |item| item[@name.length + 1 .. -1] }
>     s.select do |name|
>       name[0, prefix.length] == prefix
>     end.map { |name| SnapshotInfo.new(name, @name, prefix) }
>   end
> 
> 
> But recieves from cron:
> /usr/local/bin/zfs-snapshot-mgmt:138: syntax error, unexpected tIVAR, expecting ')'
> ... -t snapshot -H -o name '@name).readlines.collect.select { |...
>                              ^
> /usr/local/bin/zfs-snapshot-mgmt:138: syntax error, unexpected tSTRING_BEG,
> expecting '}'
> ..., @name.length + 1] == @name '@' }.map { |item| item[@name.l...
>                              ^
> /usr/local/bin/zfs-snapshot-mgmt:188: syntax error, unexpected kEND, expecting $end
> 
> /Karli
> 
> 29 jun 2012 kl. 01.20 skrev Andriy Gapon:
> 
>> on 28/06/2012 11:16 Karli Sjöberg said the following:
>>> Hi!
>>>
>>> I am a storage-technician working at the Swedish University of Agriculture
>>> and we are using zfs-snapshot-mgmt to create scheduled snapshots, but are
>>> failing on our disaster-recovery machine because of:
>>>
>>> /usr/local/bin/zfs-snapshot-mgmt:130:in `join': can't convert nil into String
>>> (TypeError)
>>> from /usr/local/bin/zfs-snapshot-mgmt:130:in `snapshots'
>>> from /usr/local/bin/zfs-snapshot-mgmt:137:in `snapshots_to_remove'
>>> from /usr/local/bin/zfs-snapshot-mgmt:145:in `remove_snapshots'
>>> from /usr/local/bin/zfs-snapshot-mgmt:213
>>> from /usr/local/bin/zfs-snapshot-mgmt:210:in `each'
>>> from /usr/local/bin/zfs-snapshot-mgmt:210
>>>
>>> Now, since this is a disaster-recovery unit, I would rather not have to have
>>> all filesystems mounted for the script to function as we have many servers
>>> with many file systems backing up towards this unit, which would result in
>>> quite alot of mounts that are completely unnecessary to the backup server
>>> itself. I also consider it a potential security risk having all these file
>>> systems, from all of these different machines mounted in the same
>>> place(server). I mean, if someone would like to steal as much valuable data
>>> as possible, why crack hundreds of servers and steal it piece by piece when
>>> you could just crack one and have it all, right? That doesn´t really make
>>> sense because if someone were to crack the backup server they could just
>>> mount all filesystems themselves, but only if they knew they were there. But
>>> also having them mounted feels like just handing it to them.
>>>
>>> Unfortunately I know nothing about programming so I can´t be of any help,
>>> besides testing patches, but do you think this can be done? Change the script
>>> so that it doesn´t require the file systems to be mounted for it to be able
>>> to take snapshots?
>>
>> How about this?
>>
>> --- zfs-snapshot-mgmt2010-06-02 05:31:28.759931924 +0300
>> +++ zfs-snapshot-mgmt2010-06-01 01:49:46.665034414 +0300
>> @@ -127,8 +127,10 @@
>>   end
>>
>>   def snapshots(prefix)
>> -    path = File.join(@mount_point, '.zfs', 'snapshot')
>> -    Dir.open(path).select do |name|
>> +#    path = File.join(@mount_point, '.zfs', 'snapshot')
>> +#    Dir.open(path).select do |name|
>> +    s = IO.popen('zfs list -r -t snapshot -H -o name ' +
>> @name).readlines.collect.select { |item| item[0, @name.length + 1] == @name +
>> '@' }.map { |item| item[@name.length + 1 .. -1] }
>> +    s.select do |name|
>>       name[0, prefix.length] == prefix
>>     end.map { |name| SnapshotInfo.new(name, @name, prefix) }
>>   end
>>
>>
>>
>> -- 
>> Andriy Gapon
>>
> 
> 
> 
> Med Vänliga Hälsningar
> -------------------------------------------------------------------------------
> Karli Sjöberg
> Swedish University of Agricultural Sciences
> Box 7079 (Visiting Address Kronåsvägen 8)
> S-750 07 Uppsala, Sweden
> Phone:  +46-(0)18-67 15 66
> karli.sjoberg@slu.se <mailto:karli.sjoberg@adm.slu.se>
> 


-- 
Andriy Gapon





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4FED54A0.7040209>