- Timestamp:
- 11/30/21 23:36:30 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-sync
r2500 r2501 17 17 18 18 la-sync [options] 19 la-sync --from source --to dest -o type [- a|obj1 obj2]19 la-sync --from source --to dest -o type [--all|obj1 obj2] 20 20 21 21 =cut … … 33 33 'b|batch' => \my $batch, 34 34 'unexp' => \my $unexp, 35 'a|all' => \my $all 35 'all' => \my $all, 36 'a|attr=s' => \my @attrs, 36 37 ) or pod2usage(); 37 38 … … 82 83 Sync unexported objects in source base 83 84 85 =item -a|--attr 86 87 Can be given multiple time, works only when oject type is given 88 89 Sync only this attributes. 90 91 If the destination attributes must be differents it can be given using a semi colon: 92 93 94 To copy sn attribute sn from source to dest objects 95 96 --attr sn 97 98 To copy sn attribute to uid on dest: 99 100 --aatr sn:uid 101 84 102 =back 85 103 … … 115 133 } 116 134 117 foreach (@list) { 118 warn "Try to sync $otype: $_\n"; 119 $sync->sync_object($otype, $_, onepass => 1) or do { 120 warn "Error while synching $_ ($otype)\n"; 121 exit 1; 135 if ( @attrs ) { 136 137 foreach my $id ( @list ) { 138 my $srcOjb = $sync->from->get_object($otype, $id) or next; 139 foreach my $dest ( $sync->to ) { 140 my $destObj = $dest->get_object($otype, $id) or next; 141 my %destvalue; 142 foreach ( sort @attrs ) { 143 m/([^:]+)(?::(.*))?/; 144 $destvalue{ $1 } = $srcOjb->get_c_field( $2 || $1 ); 145 } 146 $destObj->set_c_fields( %destvalue ); 147 $dest->commit; 148 } 149 } 150 } else { 151 foreach (@list) { 152 warn "Try to sync $otype: $_\n"; 153 $sync->sync_object($otype, $_, onepass => 1) or do { 154 warn "Error while synching $_ ($otype)\n"; 155 exit 1; 156 } 122 157 } 123 158 }
Note: See TracChangeset
for help on using the changeset viewer.