skip to main content
Roche logo
5. Data Management Topics : 5.1 backupScript.sh
#!/bin/bash
################################################################################
##
##    Filename:   backupScript.sh
##
##    Programmer: Bernard Puc
##
##    Description:
##
##          Runs at completion of the fluidics.
##
##    $Id: backupScript.sh,v 1.7 2005/01/20 15:59:23 bpuc Exp $
##
################################################################################
 
if [ $# -ne 1 ]
then
      echo "Need to specify a directory on the command line."
      echo "Exiting."
      exit 1
fi
 
#
#     Initialize the backup status variable as failed
#
RET_ERR=1
 
#
#     Update the backup status file
#
backupLog $1 "running" "permanent"
 
 
# =======================================
# =======================================
#
#     Add custom backup code here...
#
 
# The first argument is the fully qualified pathname of the Run directory
RUN_SRC=$1
 
# The destination directory "/mnt/backupServer" must already be configured via
# nfs, samba, etc.
DEST_SERVER=/mnt/backupServer
RUN_DEST=$DEST_SERVER/$RUN_SRC
 
# Copy all regular files (purposely allowing subdirectories to fail)
cp -p $RUN_SRC/* $RUN_DEST
if [ $? -ne 0 ]
then
      RET_ERR=1
else
      # Now explicitly copy subdirectory containing raw images
      cp -rp $RUN_SRC/rawImages $RUN_DEST
      if [ $? -ne 0 ]
      then
            RET_ERR=1
      fi
fi
 
# =======================================
# =======================================
 
#
#     Update the backup status file
#
if [ $RET_ERR -eq 0 ]
then
      backupLog $1 "complete" "permanent"
else
      backupLog $1 "failure" "permanent"
fi
 
#
#     End of script
#
exit 0