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

* Re: [sup-talk] Fwd: Automatic labels backup
  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
  1 sibling, 1 reply; 5+ messages in thread
From: William Morgan @ 2009-12-19 19:02 UTC (permalink / raw)
  To: sup-talk

Reformatted excerpts from Edward Z. Yang's message of 2009-12-14:
> 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.

Thanks, great idea and thank you for adding it to the wiki. I assume you
put this in the startup hooks file?
-- 
William <wmorgan-sup@masanjin.net>
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


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

* Re: [sup-talk] Fwd: Automatic labels backup
  2009-12-19 19:02 ` William Morgan
@ 2009-12-19 19:13   ` Edward Z. Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Edward Z. Yang @ 2009-12-19 19:13 UTC (permalink / raw)
  To: William Morgan; +Cc: sup-talk

Excerpts from William Morgan's message of Sat Dec 19 14:02:40 -0500 2009:
> Thanks, great idea and thank you for adding it to the wiki. I assume you
> put this in the startup hooks file?

Yep!

Edward
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


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

* Re: [sup-talk] Fwd: Automatic labels backup
  2009-12-15  5:35 [sup-talk] Fwd: Automatic labels backup Edward Z. Yang
  2009-12-19 19:02 ` William Morgan
@ 2009-12-19 23:57 ` William Baxter
  2009-12-21 16:35   ` William Morgan
  1 sibling, 1 reply; 5+ messages in thread
From: William Baxter @ 2009-12-19 23:57 UTC (permalink / raw)
  To: sup-talk

Excerpts from Edward Z. Yang's message of Tue Dec 15 00:35:42 -0500 2009:
> 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.

For a few weeks I have used sup to read the same mail on two hosts: an office
desktop and a laptop.  Each host fetches mail from the same IMAP server.  I use
the desktop all day, altering labels frequently, and consequently find reading
from the laptop less useful.  I want to sync labels across the two hosts.

How much additional work does it take to turn an index dump into a sup-to-sup
sync mechanism?  Suppose that on one host you dump the index and send a signed
message.  This reaches the receiving host when you read mail there.  Use it to
update the index, and the receiving host has labels matching those on the
sending host.

Cheers, W.
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


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

* Re: [sup-talk] Fwd: Automatic labels backup
  2009-12-19 23:57 ` William Baxter
@ 2009-12-21 16:35   ` William Morgan
  0 siblings, 0 replies; 5+ messages in thread
From: William Morgan @ 2009-12-21 16:35 UTC (permalink / raw)
  To: sup-talk

Reformatted excerpts from William Baxter's message of 2009-12-19:
> How much additional work does it take to turn an index dump into a
> sup-to-sup sync mechanism?  Suppose that on one host you dump the
> index and send a signed message.  This reaches the receiving host when
> you read mail there.  Use it to update the index, and the receiving
> host has labels matching those on the sending host.

It might not be fast or pretty, but should be easy. To sync an index
on computer B based on a dump from computer A, you should be able to
just:

computer B> sup-sync --restore <dumpfile from A>

That should both a) load any new messages from the source, and b) update
them with the labels from the dumpfile.

It's a little silly because you're transmitting the dumpfile for the
entire index back and forth between the two. If it were ordered, you
could just take a portion of it.

I've never tried this, but based on a visual inspection of the code, I
Guarantee It Works (tm).
-- 
William <wmorgan-sup@masanjin.net>
_______________________________________________
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