#!/usr/bin/perl -w
# Copyright (C) 2019-2020 all contributors
# License: AGPL-3.0+
# xcpdb: Xapian copy database, a wrapper around Xapian's copydatabase(1)
use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
use PublicInbox::InboxWritable;
use PublicInbox::Xapcmd;
use PublicInbox::Admin;
PublicInbox::Admin::require_or_die('-search');
my $usage = "Usage: public-inbox-xcpdb [--compact] INBOX_DIR\n";
my $opt = {};
my @opt = (qw(compact reshard|R=i), @PublicInbox::Xapcmd::COMPACT_OPT);
GetOptions($opt, @opt) or die "bad command-line args\n$usage";
my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV) or die $usage;
foreach (@ibxs) {
my $ibx = PublicInbox::InboxWritable->new($_);
# we rely on --no-renumber to keep docids synched to NNTP
PublicInbox::Xapcmd::run($ibx, 'cpdb', $opt);
}