]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/scripts/disk-changer.in
Add make_catalog_backup.pl script that uses env variables and
[bacula/bacula] / bacula / scripts / disk-changer.in
index f9c800cc0ebb7709b4e41462b571f1abc2407500..ccb958ba06dd58aea4585088ba7858a0edc301ed 100644 (file)
@@ -280,19 +280,21 @@ case $cmd in
 
       # we print drive content seen by autochanger
       # and we also remove loaded media from the barcode list
-      for i in $dir/loaded*
-      do
-          d=${i##$dir/loaded}
-          s=$(cat $i)
-          v=$(awk -F: "/^$s:/"' { print $2 }' $dir/barcodes)
-          echo "D:$d:F:$s:$v"
-          echo "^$s:" >> $TMPFILE
+      i=0
+      while [ $i -le $maxdrive ]; do
+        if [ -f $dir/loaded${i} ]; then
+             ld=`cat $dir/loaded${i}`
+             v=`awk -F: "/^$ld:/"' { print $2 }' $dir/barcodes`
+             echo "D:$i:F:$ld:$v"
+             echo "^$ld:" >> $TMPFILE
+        fi
+        i=`expr $i + 1`
       done
 
       # Empty slots are not in barcodes file
       # When we detect a gap, we print missing rows as empty
       # At the end, we fill the gap between the last entry and maxslot
-      grep -v -f $TMPFILE $dir/barcodes | \
+      grep -v -f $TMPFILE $dir/barcodes | sort -n | \
       perl -ne 'BEGIN { $cur=1 } 
        if (/(\d+):(.+)?/) {
          if ($cur == $1) {