From: "Edward Z. Yang" <ezyang@MIT.EDU>
To: sup-talk <sup-talk@rubyforge.org>
Subject: [sup-talk] Fwd: Automatic labels backup
Date: Tue, 15 Dec 2009 00:35:42 -0500 [thread overview]
Message-ID: <1260855317-sup-863@ezyang> (raw)
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
next reply other threads:[~2009-12-15 5:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-15 5:35 Edward Z. Yang [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1260855317-sup-863@ezyang \
--to=ezyang@mit.edu \
--cc=sup-talk@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox