--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use RRDs;
+
+sub usage {
+ print("usage: mvrrd.pl src.rrd dst.rrd start end\n");
+}
+
+usage() if scalar(@ARGV) != 4;
+
+my $src = @ARGV[0];
+my $dst = @ARGV[1];
+my $start = $ARGV[2];
+my $end = $ARGV[3];
+
+sub RRDupdate {
+ my $time = shift;
+ my $val = shift;
+
+ my @arg = ();
+
+ push @arg, $dst;
+ push @arg, "$time:$val";
+ RRDs::update(@arg);
+ my $error = RRDs::error;
+ die "RRD error: $error\n" if $error;
+}
+
+my @arg = ();
+push @arg, "$src";
+push @arg, "AVERAGE";
+push @arg, "--start", $start;
+push @arg, "--end", $end;
+
+my ($dataStart,$step,$names,$data) = RRDs::fetch(@arg);
+my $error = RRDs::error;
+die "RRD error: $error\n" if $error;
+print "Start: ", scalar localtime($dataStart), " ($dataStart)\n";
+print "Step size: $step seconds\n";
+print "DS names: ", join (", ", @$names)."\n";
+print "Data points: ", $#$data + 1, "\n";
+print "Data:\n";
+for my $line (@$data) {
+# print " ", scalar localtime($dataStart), " ($dataStart) ";
+ my ($sec, $min, $hour, $mday, $mon, $year) = localtime($dataStart);
+ my $isoDate = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $mday);
+ for my $val (@$line) {
+# printf "%f ", $val;
+ $val = 'U' if !defined $val;
+# print "val: $val @ time $isoDate";
+# print " ... Updating dst";
+ RRDupdate($dataStart, $val);
+ }
+ $dataStart += $step;
+# print "\n";
+}