Listing 1 -- Main program logic from Backup.TCL >>
  #
  # Main Backup logic
  proc main { } {

    # Get the resources and cache the Backup Targets ...
    sql::openDBMS 
    set N_Res [ sql::readResources ]
    set N_Targets [ sql::cache_tbl_Data target ]
    sql::closeDBMS 
    set iso_dir [file join $::X(archive_path) Nightly]
    set iso_img [file join $::X(archive_path) Nightly.iso]

    sys::new_Log
    file delete -force $iso_dir
    file delete -force $iso_img
    file mkdir $iso_dir
    set start [ sys::startup Backup ]

    set n_Bytes 0 
    set n_Total 0 
    for { set i 0 } { $i < $N_Targets } { incr i } {
      array set t [ sql::get_tbl_Row $i ]
      set n_Bytes [ backup_Target $i ] 
      puts " -- Archived $n_Bytes bytes."
      sys::sys_Error_Report $t(name)
      set n_Total [expr $n_Total + $n_Bytes ]
      sys::reset_Net
    }

    set m_Bytes [ expr $n_Total / [ expr 1024 * 1024 ] ]
    set end [ sys::finish Backup ]
    puts " -- Total Bytes $n_Total (about $m_Bytes Meg)."
    puts " -- Elapsed Time: [ sys::elapsed [ expr $end - $start ] ]."
		
    sys::burn_DIR $iso_dir
    sys::mount_cd9660 /cdrom
    sys::do_SysCmd "/bin/ls -lh /cdrom"
    puts $sys::sys_result
    sys::umount_cd9660 /cdrom
    sys::close_Log
  }

}
bkp::main
