X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rt%2Fsbin%2Frt-serializer.in;h=37ec7fa3cafb271b3a890602a31213b1bcc2d206;hb=44dd00a3ff974a17999e86e64488e996edc71e3c;hp=0e01744725f7982a23feffa955563c22a706242d;hpb=026dc7ad72ba972f230b6709e31fa64397d75ad4;p=freeside.git diff --git a/rt/sbin/rt-serializer.in b/rt/sbin/rt-serializer.in index 0e0174472..37ec7fa3c 100644 --- a/rt/sbin/rt-serializer.in +++ b/rt/sbin/rt-serializer.in @@ -3,7 +3,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -104,6 +104,9 @@ GetOptions( "scrips!", "tickets!", "acls!", + "limit-queues=s@", + "limit-cfs=s@", + "hyperlink-unmigrated!", "clone", "incremental", @@ -127,12 +130,53 @@ $args{FollowScrips} = $OPT{scrips} if defined $OPT{scrips}; $args{FollowTickets} = $OPT{tickets} if defined $OPT{tickets}; $args{FollowACL} = $OPT{acls} if defined $OPT{acls}; +$args{HyperlinkUnmigrated} = $OPT{'hyperlink-unmigrated'} if defined $OPT{'hyperlink-unmigrated'}; + $args{Clone} = $OPT{clone} if $OPT{clone}; $args{Incremental} = $OPT{incremental} if $OPT{incremental}; $args{GC} = defined $OPT{gc} ? $OPT{gc} : 5000; $args{Page} = defined $OPT{page} ? $OPT{page} : 100; +if ($OPT{'limit-queues'}) { + my @queue_ids; + + for my $name (split ',', join ',', @{ $OPT{'limit-queues'} }) { + $name =~ s/^\s+//; $name =~ s/\s+$//; + my $queue = RT::Queue->new(RT->SystemUser); + $queue->Load($name); + if (!$queue->Id) { + die "Unable to load queue '$name'"; + } + push @queue_ids, $queue->Id; + } + + $args{Queues} = \@queue_ids; +} + +if ($OPT{'limit-cfs'}) { + my @cf_ids; + + for my $name (split ',', join ',', @{ $OPT{'limit-cfs'} }) { + $name =~ s/^\s+//; $name =~ s/\s+$//; + + # numeric means id + if ($name =~ /^\d+$/) { + push @cf_ids, $name; + } + else { + my $cfs = RT::CustomFields->new(RT->SystemUser); + $cfs->Limit(FIELD => 'Name', VALUE => $name); + if (!$cfs->Count) { + die "Unable to load any custom field named '$name'"; + } + push @cf_ids, map { $_->Id } @{ $cfs->ItemsArrayRef }; + } + } + + $args{CustomFields} = \@cf_ids; +} + if (($OPT{clone} or $OPT{incremental}) and grep { /^(users|groups|deleted|scrips|tickets|acls)$/ } keys %OPT) { die "You cannot specify object types when cloning.\n\nPlease see $0 --help.\n"; @@ -321,6 +365,24 @@ serialized. Skip serialization of all ticket data. +=item B<--limit-queues> + +Takes a list of queue IDs or names separated by commas. When provided, only +that set of queues (and the tickets in them) will be serialized. + +=item B<--limit-cfs> + +Takes a list of custom field IDs or names separated by commas. When provided, +only that set of custom fields will be serialized. + +=item B<--hyperlink-unmigrated> + +Replace links to local records which are not being migrated with hyperlinks. +The hyperlinks will use the serializing RT's configured URL. + +Without this option, such links are instead dropped, and transactions which +had updated such links will be replaced with an explanatory message. + =item B<--clone> Serializes your entire database, creating a clone. This option should