From ac5a695030be64059fcb1ae826a0f3bfd2ca035b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 23 May 2019 09:36:46 +0000 Subject: xcpdb: new tool which wraps Xapian's copydatabase(1) copydatabase(1) is an existing Xapian tool which is the recommended way to upgrade existing DBs to the latest Xapian database format (currently "glass" for stable/released versions). Our use of Xapian relies on preserving document IDs, so we'll wrap it like we do xapian-compact(1) and use the "--no-renumber" switch. I could not name the tool "public-inbox-copydatabase" since it would be ambiguous as to which DB it's actually copying. So, I abbreviated the suffix to "xcpdb" (Xapian CoPy DataBase), which I hope is acceptable and unambiguous. --- script/public-inbox-xcpdb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 script/public-inbox-xcpdb (limited to 'script') diff --git a/script/public-inbox-xcpdb b/script/public-inbox-xcpdb new file mode 100755 index 00000000..cbf9f556 --- /dev/null +++ b/script/public-inbox-xcpdb @@ -0,0 +1,18 @@ +#!/usr/bin/perl -w +# Copyright (C) 2019 all contributors +# License: AGPL-3.0+ +# xcpdb: Xapian copy database, a wrapper around Xapian's copydatabase(1) +use PublicInbox::InboxWritable; +use PublicInbox::Xapcmd; +use PublicInbox::Admin; +PublicInbox::Admin::require_or_die('-search'); +my $usage = "Usage: public-inbox-xcpdb INBOX_DIR\n"; +my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV) or die $usage; +my $cmd = [qw(copydatabase --no-renumber)]; +open my $null, '>', '/dev/null' or die "failed to open /dev/null: $!\n"; +my $rdr = { 1 => fileno($null) }; +foreach (@ibxs) { + my $ibx = PublicInbox::InboxWritable->new($_); + # we rely on --no-renumber to keep docids synched to NNTP + PublicInbox::Xapcmd::run($ibx, $cmd, undef, $rdr); +} -- cgit v1.2.3-24-ge0c7