Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] Fwd: Automatic labels backup
@ 2009-12-15  5:35 Edward Z. Yang
  2009-12-19 19:02 ` William Morgan
  2009-12-19 23:57 ` William Baxter
  0 siblings, 2 replies; 5+ messages in thread
From: Edward Z. Yang @ 2009-12-15  5:35 UTC (permalink / raw)
  To: sup-talk

Ever had your index corrupted, and your last backup of your labels from
a month ago?  Ever had to go speed through a month's worth of mail?

Well, now, you can /not/ have to do that, with a handy-dandy automated
index dump tool that I've written.  It's at the bottom of the
hooks page here: <http://sup.rubyforge.org/wiki/wiki.pl?Hooks> and I've
reproduced it below for completeness.

This is the first substantial bit of Ruby code I've ever written, so
style nits as well as improvements greatly welcomed; in particular
automatic gzipping of the dumpfiles, and maybe a less braindead backup
rotation technique.

Cheers,
Edward

require 'ftools'

Redwood::reporting_thread("dump") do
    maintain = 7
    wait = 21600
    while true
        say "Rotating dumps"
        filename = File.join(BASE_DIR, "dump")
        maintain.downto(0) do |i|
            rotatename = filename + "." + i.to_s
            if File.exist?(rotatename)
                if i == maintain
                    File.unlink(rotatename)
                else
                    File.move(rotatename, filename + "." + (i+1).to_s)
                end
            end
        end
        say "Dumping labels to .sup/dump.0"
        dumpfile = File.new(filename + ".0", "w")
        Redwood::Index.each_message :load_spam => true, :load_deleted => true, :load_killed => true do |m|
            dumpfile.puts "#{m.id} (#{m.labels.to_a.sort_by { |l| l.to_s } * ' '})"
        end
        dumpfile.close
        say "Done dumping"
        sleep wait
    end
end
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-12-21 16:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-15  5:35 [sup-talk] Fwd: Automatic labels backup Edward Z. Yang
2009-12-19 19:02 ` William Morgan
2009-12-19 19:13   ` Edward Z. Yang
2009-12-19 23:57 ` William Baxter
2009-12-21 16:35   ` William Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox