Subversion Repositories zfs_utils

Rev

Rev 4 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 5
Line 140... Line 140...
140
#   }
140
#   }
141
#   return 1;
141
#   return 1;
142
#}
142
#}
143
   
143
   
144
sub createCommands {
144
sub createCommands {
145
   my ( $config->{'source'}, $config->{'target'}, $config ) = @_;
145
   my ( $lastSource, $lastTarget, $config ) = @_;
146
   my @return;
146
   my @return;
147
   # check for new snapshots to sync
147
   # check for new snapshots to sync
148
   if ( $config->{'source'} ne $config->{'target'} ) {
148
   if ( $lastSource ne $lastTarget ) {
-
 
149
      my $snapRange = $config->{'target'}->{'dataset'} . '@' . $config->{'target'};
-
 
150
      my $flags = ( $config->{'recurse'} ? 'R' : '' ) .
-
 
151
                  ( $config->{'verbose'} == 2 ? 'v' : '' );
-
 
152
      my $source = $config->{'source'}->{'dataset'} . '@' . $lastSource;
-
 
153
      my $target = $config->{'target'}->{'dataset'};
149
      # first create the replicate command. The send command request recursion (-R)
154
      # first create the replicate command. The send command request recursion (-R)
150
      # and the range of snapshots including all intermediate ones (-I)
155
      # and the range of snapshots including all intermediate ones (-I)
151
      my $config->{'source'}Command = 'zfs send -RI ';
156
      my $command = 'zfs send -RI ';
152
      $config->{'source'}Command .= $config->{'source'}->{'dataset'} . '@' . $config->{'target'} . ' ';
157
      $command .= $config->{'target'}->{'dataset'} . '@' . $config->{'target'} . ' ';
153
      $config->{'source'}Command .= $config->{'source'}->{'dataset'} . '@' . $config->{'source'};
158
      $command .= $config->{'source'}->{'dataset'} . '@' . $config->{'source'};
154
      $config->{'source'}Command = "ssh $config->{source}->{server} '$config->{'source'}Command'" if $config->{'source'}->{'server'};
159
      $command = "ssh $config->{source}->{server} '$config->{'source'}Command'" if $config->{'source'}->{'server'};
155
 
160
 
156
      my $config->{'target'}Command = 'zfs receive -v ';
161
      $command = 'zfs receive -v ';
157
      $config->{'target'}Command .= $config->{'target'}->{'dataset'};
162
      $command .= $config->{'target'}->{'dataset'};
158
      $config->{'target'}Command = "ssh $config->{target}->{server} '$config->{'source'}Command'" if $config->{'target'}->{'server'};
163
      $command = "ssh $config->{target}->{server} '$config->{'source'}Command'" if $config->{'target'}->{'server'};
159
      push @return, $config->{'source'}Command . ' | ' . $config->{'target'}Command;
164
      push @return, $command . ' | ' . $command;
160
   } else {
165
   } else {
161
      push @return, '# Nothing new to sync';
166
      push @return, '# Nothing new to sync';
162
   }
167
   }
163
   # now, check for snapshots to remove
168
   # now, check for snapshots to remove
164
   #if ( $config->{'actions'}->{'deleteTarget'} ) {
169
   #if ( $config->{'actions'}->{'deleteTarget'} ) {