about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-23 09:36:46 +0000
committerEric Wong <e@80x24.org>2019-05-23 17:43:50 +0000
commitac5a695030be64059fcb1ae826a0f3bfd2ca035b (patch)
tree316fd6d6a1ece471b8e0a6996c8e1a9c6f73d162 /script
parentf0cc8e6795077bc7a04e579655a1c5e90c80a4e8 (diff)
downloadpublic-inbox-ac5a695030be64059fcb1ae826a0f3bfd2ca035b.tar.gz
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.
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-xcpdb18
1 files changed, 18 insertions, 0 deletions
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 <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+# 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);
+}