Index: trunk/tools/eam/rebalance/neb_check_reinsert.pl
===================================================================
--- trunk/tools/eam/rebalance/neb_check_reinsert.pl	(revision 41507)
+++ trunk/tools/eam/rebalance/neb_check_reinsert.pl	(revision 41508)
@@ -157,13 +157,4 @@
     my $vol_id_actual = $values[0];
 
-    ## print "NROWS: $Nrows\n";
-    ## foreach my $valref (@array) {
-    ## 	my @values = @$valref;
-    ## 	foreach my $value (@values) {
-    ## 	    print "VAL: $value, ";
-    ## 	}
-    ## 	print "\n";
-    ## }
-
     if ($vol_id_actual != $tgt_vol_id) {
 	print "ERROR : INVALID VOL_ID: $summary\n";
Index: trunk/tools/eam/rebalance/neb_check_trash.pl
===================================================================
--- trunk/tools/eam/rebalance/neb_check_trash.pl	(revision 41507)
+++ trunk/tools/eam/rebalance/neb_check_trash.pl	(revision 41508)
@@ -54,5 +54,9 @@
 my $dbh = DBI->connect($dsn, $dbuser, $dbpass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
 
-unless (mkdir $savedir) { die "failed to make savedir\n"; }
+if (-e $savedir) {
+    unless (-d $savedir) { die "savedir $savedir exists but is not a directory\n"; }
+} else {
+    unless (mkdir $savedir) { die "failed to make savedir\n"; }
+}
 
 my @files = <${trashdir}/*>;
Index: trunk/tools/eam/rebalance/neb_find_broken_links.pl
===================================================================
--- trunk/tools/eam/rebalance/neb_find_broken_links.pl	(revision 41507)
+++ 	(revision )
@@ -1,28 +1,0 @@
-#!/usr/bin/env perl
-use strict;
-
-if (@ARGV < 1) { die "USAGE: neb_find_broken_links.pl (dsProduct)\n"; }
-
-my $dsProduct = $ARGV[0];
-
-my @dsFilesets = <$dsProduct/*>;
-
-foreach my $dsFileset (@dsFilesets) {
-
-    print "FILESET: $dsFileset\n";
-
-    my @dsFiles = <$dsFileset/*>;
-
-    foreach my $dsFile (@dsFiles) {
-
-	# is this a real link?
-	if (! -l $dsFile) { next; }
-
-	# is it just fantasy?
-	if (  -e $dsFile) { next; }
-
-	print "BADLINK: $dsFile\n";
-    }
-}
-
-exit 0;
Index: trunk/tools/eam/rebalance/neb_find_bundles.sh
===================================================================
--- trunk/tools/eam/rebalance/neb_find_bundles.sh	(revision 41507)
+++ 	(revision )
@@ -1,9 +1,0 @@
-#!/bin/csh -f
-
-if ($#argv != 1) then
-  echo "USAGE: neb_find_datastore_bundles.sh (movelist)"
-  exit 2
-endif
-
-grep 'tgz$' /data/ipp107.1/nebulous/69/rebalance/movefiles.20200709.txt
-
Index: trunk/tools/eam/rebalance/rebalance.mana
===================================================================
--- trunk/tools/eam/rebalance/rebalance.mana	(revision 41507)
+++ trunk/tools/eam/rebalance/rebalance.mana	(revision 41508)
@@ -40,8 +40,8 @@
   # generate the full paths:
   $source = /data/$srchost.$srcvol/nebulous
-  # $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous
+  $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous
 
   ## make sure target exists
-  # mkdir $target
+  mkdir $target
 
   ## this script must be run on the same machine as the source
@@ -106,5 +106,5 @@
 
   ## make sure target exists
-  # mkdir $target
+  mkdir $target
 
   ## this script must be run on the same machine as the source
@@ -159,9 +159,4 @@
     sprintf movelog  %s/rebalance/movefiles.%s.log $srcdir $VERSION
     sprintf subdirset "%s/??" $srcdir
-
-    local isFound
-    file $movelist isFound
-    if ($isFound) continue
-
     exec find $subdirset -size +$BIGSIZE > $filelist
 
@@ -221,17 +216,4 @@
   $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous
 
-  ## make sure target exists
-  mkdir $target
-
-  $TIMEFORMAT = mjd
-  $TIMEREF = 2000/01/01,00:00:00; # this is not used but required to exist for ctimes
-  
-  # give the start of the night in HST hours:
-  $HSTNightStart = 18.5
-  $HSTNightEnd   =  7.5
-
-  $UTNightStart = ($HSTNightStart + 10) / 24; $UTNightStart = $UTNightStart - int($UTNightStart)
-  $UTNightEnd   = ($HSTNightEnd   + 10) / 24; $UTNightEnd   = $UTNightEnd   - int($UTNightEnd)
-
   for i 0 $NSUBDIR
     sprintf srcdir "%s/%02x" $source $i
@@ -242,4 +224,39 @@
     sprintf movelist %s/rebalance/movefiles.%s.txt $srcdir $VERSION
     sprintf movelog  %s/rebalance/movefiles.%s.log $srcdir $VERSION
+
+    echo "rsyncing $srcdir/ to $tgtdir/ : $movelog"
+    exec rsync -auv --files-from=$movelist $srcdir/ $tgtdir/ >& $movelog
+  end
+end
+
+macro run.rsync.check
+  if ($0 != 7)
+    echo "USAGE: run.rsync.check (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) (OUTVER)"
+    echo "srchost, tgthost : e.g., ipp070"
+    echo "srcvol, tgtvol   : e.g., 0 (for /data/ipp070.0/nebulous)"
+    break
+  end
+
+  local srchost srcvol tgthost tgtvol
+
+  $srchost = $1
+  $srcvol = $2
+  $tgthost = $3
+  $tgtvol = $4
+  $VERSION = $5
+  $OUTVER  = $6
+
+  # generate the full paths:
+  $source = /data/$srchost.$srcvol/nebulous
+  $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous
+
+  for i 0 $NSUBDIR
+    sprintf srcdir "%s/%02x" $source $i
+    sprintf tgtdir "%s/%02x" $target $i
+    # echo $srcdir
+
+    # generate initial file list (all big files)
+    sprintf movelist %s/rebalance/movefiles.%s.txt $srcdir $VERSION
+    sprintf movelog  %s/rebalance/movefiles.%s.log $srcdir $OUTVER
 
     echo "rsyncing $srcdir/ to $tgtdir/ : $movelog"
@@ -247,51 +264,4 @@
     exec rsync -auv --files-from=$movelist $srcdir/ $tgtdir/ >& $movelog
     break -auto on
-
-    # check the time: is it night time (sleep and restart later)
-    $isNight = 1
-    while ($isNight)
-      ctimes -abs now -var tnow
-      $tfrac = $tnow - int($tnow)
-      $isNight = (($tfrac > $UTNightStart) && ($tfrac < $UTNightEnd))
-      if ($isNight) 
-        echo "it is night time, sleeping until the morning"
-        sleep 600
-      end
-    end
-  end
-end
-
-macro run.rsync.check
-  if ($0 != 7)
-    echo "USAGE: run.rsync.check (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) (OUTVER)"
-    echo "srchost, tgthost : e.g., ipp070"
-    echo "srcvol, tgtvol   : e.g., 0 (for /data/ipp070.0/nebulous)"
-    break
-  end
-
-  local srchost srcvol tgthost tgtvol
-
-  $srchost = $1
-  $srcvol = $2
-  $tgthost = $3
-  $tgtvol = $4
-  $VERSION = $5
-  $OUTVER  = $6
-
-  # generate the full paths:
-  $source = /data/$srchost.$srcvol/nebulous
-  $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous
-
-  for i 0 $NSUBDIR
-    sprintf srcdir "%s/%02x" $source $i
-    sprintf tgtdir "%s/%02x" $target $i
-    # echo $srcdir
-
-    # generate initial file list (all big files)
-    sprintf movelist %s/rebalance/movefiles.%s.txt $srcdir $VERSION
-    sprintf movelog  %s/rebalance/movefiles.%s.log $srcdir $OUTVER
-
-    echo "rsyncing $srcdir/ to $tgtdir/ : $movelog"
-    exec rsync -auv --files-from=$movelist $srcdir/ $tgtdir/ >& $movelog
   end
 end
@@ -420,5 +390,5 @@
   end
 
-  local srchost tgthost srcvol tgtvol
+  local srchost tgthost srcvol tgtvol isFound myfile
 
   $srchost = $1
@@ -447,6 +417,13 @@
     for j 0 $files:n
       # move the file to the trash directory
-      echo mv $srcdir/$files:$j $trashdir
-      exec mv $srcdir/$files:$j $trashdir
+      
+      $myfile = $srcdir/$files:$j
+      file $myfile isFound
+      if (not($isFound)) 
+        echo "$myfile not found, skipping"
+        continue
+      end
+      echo mv $myfile $trashdir
+      exec mv $myfile $trashdir
     end
   end
@@ -495,4 +472,89 @@
   else
     echo "SUCCESS: no check errors detected"
+  end
+end
+
+# names are defined for a single src & tgt pair
+macro run.location.check
+  if ($0 != 6)
+    echo "USAGE: run.location.check (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"
+    echo "srchost, tgthost : e.g., ipp070"
+    echo "srcvol, tgtvol   : e.g., 0 (for /data/ipp070.0/nebulous)"
+    break
+  end
+
+  local srchost tgthost srcvol tgtvol
+
+  $srchost = $1
+  $srcvol = $2
+
+  $source = /data/$srchost.$srcvol/nebulous
+
+  $tgthost = $3
+  $tgtvol = $4
+  $VERSION = $5
+  
+  $myhost = `hostname`
+  if ("$myhost" != "$tgthost")
+    echo "please run on $tgthost"
+    break
+  end
+
+  # I have a list of files in 'movelist' for which I want to check copy locations
+  # if the neb-entries have number of user copies != 2, the file is OK
+  # if the neb-entries is >= 2, one should be on a backup node
+
+  for i 0 $NSUBDIR
+    sprintf srcdir "%s/%02x" $source $i
+    sprintf subdir "%02x" $i
+
+    # generate initial file list (all big files)
+    sprintf movelist %s/rebalance/movefiles.%s.txt $srcdir $VERSION
+    sprintf checklog %s/rebalance/movefiles.%s.loc $srcdir $VERSION
+
+     echo ./neb_check_location.pl --tgthost $tgthost --tgtvol $tgtvol --subdir $subdir --list $movelist > $checklog
+    $EXEC ./neb_check_location.pl --tgthost $tgthost --tgtvol $tgtvol --subdir $subdir --list $movelist > $checklog
+  end
+end
+
+# names are defined for a single src & tgt pair
+macro run.location.fix
+  if ($0 != 6)
+    echo "USAGE: run.location.fix (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"
+    echo "srchost, tgthost : e.g., ipp070"
+    echo "srcvol, tgtvol   : e.g., 0 (for /data/ipp070.0/nebulous)"
+    break
+  end
+
+  local srchost tgthost srcvol tgtvol
+
+  $srchost = $1
+  $srcvol = $2
+
+  $source = /data/$srchost.$srcvol/nebulous
+
+  $tgthost = $3
+  $tgtvol = $4
+  $VERSION = $5
+  
+  $myhost = `hostname`
+  if ("$myhost" != "$tgthost")
+    echo "please run on $tgthost"
+    break
+  end
+
+  # I have a list of files in 'movelist' for which I want to check copy locations
+  # if the neb-entries have number of user copies != 2, the file is OK
+  # if the neb-entries is >= 2, one should be on a backup node
+
+  for i 0 $NSUBDIR
+    sprintf srcdir "%s/%02x" $source $i
+    sprintf subdir "%02x" $i
+
+    # generate initial file list (all big files)
+    sprintf movelist %s/rebalance/movefiles.%s.txt $srcdir $VERSION
+    sprintf checklog %s/rebalance/movefiles.%s.loc $srcdir $VERSION
+
+     echo ./neb_check_location.pl --tgthost $tgthost --tgtvol $tgtvol --subdir $subdir --list $movelist > $checklog
   end
 end
@@ -545,5 +607,5 @@
     echo "USAGE: rebalance.mana (MODE) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) [options]"
     echo ""
-    echo "MODE: find.test, find, rsync, rsync.check, insert, insert.check, trash, trash.check, empty.trash"
+    echo "MODE: find.test, find, rsync, rsync.check, insert, insert.check, location.check, trash, trash.check, empty.trash"
     echo ""
     echo "srchost, tgthost : e.g., ipp070"
@@ -636,4 +698,24 @@
   end
 
+  #### location.check ####
+  if ("$argv:0" == "location.check")
+    if ($argv:n != 6)
+      echo "USAGE: rebalance.mana (location.check) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"
+      break
+    end
+    run.location.check $argv:1 $argv:2 $argv:3 $argv:4 $argv:5
+    exit 0
+  end
+
+  #### location.fix ####
+  if ("$argv:0" == "location.fix")
+    if ($argv:n != 6)
+      echo "USAGE: rebalance.mana (location.fix) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"
+      break
+    end
+    run.location.fix $argv:1 $argv:2 $argv:3 $argv:4 $argv:5
+    exit 0
+  end
+
   #### empty.trash ####
   if ("$argv:0" == "empty.trash")
