{"id":2735,"date":"2014-01-28T19:54:09","date_gmt":"2014-01-28T11:54:09","guid":{"rendered":"http:\/\/rmohan.com\/?p=2735"},"modified":"2014-01-29T10:05:10","modified_gmt":"2014-01-29T02:05:10","slug":"his-script-can-start-stop-backup-and-restore-your-websphere-environment","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2735","title":{"rendered":"script  start, stop, backup and restore your WebSphere environment"},"content":{"rendered":"<pre>#!\/bin\/ksh\r\n#\r\n# Set you environment here [ACC,FOP,PRD]\r\nENV=FOP\r\n\r\n# Set your company name here\r\nCOMP=WARMETAL\r\n\r\n#\r\n# APP_HOME setting\r\nAPP_HOME=\/opt\/sft\/${COMP}-${ENV}\r\n\r\n# Change here the WAS userid, WAS group and sid if necessary\r\nWAS_USER=wasuser\r\nWAS_GROUP=wasgroup\r\nWAS_PROCESSES=\"dmgr nodeagent Front_Server Security_Server APP_Server JMS_Server\"\r\n\r\nWAS_CELL=\"${COMP}-${ENV}.cell\"\r\nWAS_NODE_EB=\"${COMP}-${ENV}.AppSrv.node\"\r\nWAS_NODE_FE=\"${COMP}-${ENV}.AppSrv.node\"\r\n\r\n# Change the location of the directory in this variable of the WAS :\r\nWAS_HOME=\/opt\/IBM\/WebSphere\/AppServer\r\nWAS_BASE_HOME=\/opt\/sft\/${COMP}-${ENV}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\r\nWAS_BASE_DATA=\/var\/data\/${COMP}-${ENV}\/WAS\r\nWAS_BASE_LOG=\/var\/log\/${COMP}-${ENV}\/WAS\r\nWAS_BASE_DUMP=\/var\/dump\/ibm\/websphere\/6.1\/BASE\r\n\r\n# Change the location of the directory in this variable of the WAS_ND :\r\nWAS_ND_HOME=\/opt\/sft\/${COMP}-${ENV}\/WAS_Profiles\/${COMP}-${ENV}.dmgr\r\nWAS_ND_DATA=\/var\/data\/${COMP}-${ENV}\/WAS_ND\r\nWAS_ND_LOG=\/var\/log\/${COMP}-${ENV}\/WAS_ND\r\nWAS_ND_DUMP=\/var\/dump\/${COMP}-${ENV}\/WAS_ND\r\n\r\n# Essential Homes\r\nWAS_UPDATE_INSTALLER_HOME=\/opt\/IBM\/UpdateInstaller\r\nWAS_IHS_HOME=\/opt\/IBM\/HTTPServer\r\n\r\nBACKUPFILEND=${WAS_ND_DUMP}\/wasbck_`date +%Y%m%d%H%M`.zip\r\nBACKUPFILEBASE=${WAS_BASE_DUMP}\/wasbck_`date +%Y%m%d%H%M`.zip\r\n\r\ncase \"$1\" in\r\n\r\nstart )\r\n  echo \"Starting the Network Deployment Manager\"\r\n  su - $WAS_USER $WAS_ND_HOME\/bin\/startManager.sh\r\n\r\n  echo \"Starting the Node\"\r\n  su - $WAS_USER $WAS_BASE_HOME\/bin\/startNode.sh\r\n\r\n  for server in Front Security APP JMS; do\r\n    echo \"Starting server $server\"\r\n    su - $WAS_USER ${ALLSHARE_HOME}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\/bin\/startServer.sh ${server}_Server\r\n  done\r\n  su - $WAS_USER ${ALLSHARE_HOME}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\/bin\/startServer.sh Monitoring_server\r\n ;;\r\n\r\nstop )\r\n  echo \"Stopping the Network Deployment Manager\"\r\n  su - $WAS_USER $WAS_ND_HOME\/bin\/stopManager.sh\r\n\r\n  echo \"Stopping the Node\"\r\n  su - $WAS_USER $WAS_BASE_HOME\/bin\/stopNode.sh -stopservers\r\n  su - $WAS_USER ${ALLSHARE_HOME}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\/bin\/stopServer.sh Monitoring_server\r\n ;;\r\n\r\nstart-node )\r\n  echo \"Starting the Node\"\r\n  su - $WAS_USER $WAS_BASE_HOME\/bin\/startNode.sh\r\n ;;\r\n\r\nstop-node )\r\n  echo \"Stopping the Node\"\r\n  su - $WAS_USER $WAS_BASE_HOME\/bin\/stopNode.sh -stopservers\r\n  su - $WAS_USER ${APP_HOME}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\/bin\/stopServer.sh Monitoring_server\r\n ;;\r\n\r\nstart-dmgr )\r\n  echo \"Starting the Network Deployment Manager\"\r\n  su - $WAS_USER $WAS_ND_HOME\/bin\/startManager.sh\r\n ;;\r\n\r\nstop-dmgr )\r\n  echo \"Stopping the Network Deployment Manager\"\r\n  su - $WAS_USER $WAS_ND_HOME\/bin\/stopManager.sh\r\n ;;\r\n\r\nstart-all )\r\n  for server in JMS APP Security Front; do\r\n    echo \"Starting server $server\"\r\n    su - $WAS_USER ${APP_HOME}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\/bin\/startServer.sh ${server}_Server\r\n  done\r\n  su - $WAS_USER ${APP_HOME}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\/bin\/startServer.sh Monitoring_server\r\n;;\r\n\r\nstop-all )\r\n  for server in Front Security APP JMS; do\r\n    echo \"Stopping server $server\"\r\n    su - $WAS_USER ${APP_HOME}\/WAS_Profiles\/${COMP}-${ENV}.AppSrv\/bin\/stopServer.sh ${server}_Server\r\n  done\r\n;;\r\n\r\nbackup )\r\n  for profile in dmgr AppSrv; do\r\n    su - $WAS_USER ${APP_HOME}\/WAS_Profiles\/${COMP}-${ENV}.${profile}\/bin\/backupConfig.sh \\\r\n      \/var\/backup\/${COMP}-${ENV}\/was\/was-config-${profile}-`date +%Y%m%d`.zip \\\r\n      -nostop \\\r\n      -logfile \/var\/backup\/${COMP}-${ENV}\/was\/was-config-${profile}-`date +%Y%m%d`.log \\\r\n      -profileName ${COMP}-${ENV}.${profile}\r\ndone\r\n;;\r\n\r\nrestore )\r\n  if [ -f \/var\/backup\/${COMP}-${ENV}\/was\/was-config-dmgr-${2}.zip -a -f \/var\/backup\/${COMP}-${ENV}\/was\/was-config-AppSrv-${2}.zip ]; then\r\n    for profile in dmgr AppSrv; do\r\n      su - $WAS_USER \/opt\/sft\/${COMP}-${ENV}\/WAS_Profiles\/${COMP}-${ENV}.${profile}\/bin\/restoreConfig.sh \\\r\n        \/var\/backup\/${COMP}-${ENV}\/was\/was-config-${profile}-`date +%Y%m%d`.zip \\\r\n        -logfile \/var\/backup\/${COMP}-${ENV}\/was\/was-config-${profile}-`date +%Y%m%d`.log \\\r\n        -profileName ${COMP}-${ENV}.${profile}\r\n    done\r\n  else\r\n     if [ ! \"$2\" = \"\" ]; then\r\n       echo \"Cannot find or read (all) backup files, searching for:\"\r\n       echo \/var\/backup\/${COMP}-${ENV}\/was\/was-config-dmgr-${2}.zip\r\n       echo \/var\/backup\/${COMP}-${ENV}\/was\/was-config-AppSrv-${2}.zip\r\n       echo\r\n     else\r\n       echo \"Please specify the date (YYYYMMDD) to restore as argument\"\r\n       echo \"Available dates currently under backup:\"\r\n       ls -1 \/var\/backup\/${COMP}-${ENV}\/was\/was-config-*.zip | awk -F - '{ print $5 }' | \\\r\n       sed 's\/.zip\/\/g' | sort | uniq\r\n       echo\r\n     fi\r\n    exit 1\r\n  fi\r\n;;\r\n\r\nstatus )\r\nfor i in $WAS_PROCESSES; do\r\n    unset pid\r\n    pid=`ps -ef|grep $i| grep $i|grep -v grep|awk '{ print $2 }'`\r\n    if [[ \"$pid\" = \"\" ]] then\r\n      echo \"WAS subprocess $i is stopped...\"\r\n      echo\r\n      exit 0\r\n    else\r\n      echo \"WAS subprocess $i is running using processed $pid\"\r\n    fi\r\n  done\r\n  echo\r\n  exit 1\r\n;;\r\n\r\ninfo )\r\n  # WAS instance information, version, etc...\r\n  echo \"Information of the Deployment Manager\"\r\n  su - $WAS_USER ${WAS_ND_HOME}\/bin\/versionInfo.sh\r\n\r\n  echo\r\n  echo \"Information of AppSrv Node\"\r\n  su - $WAS_USER ${WAS_BASE_HOME}\/bin\/versionInfo.sh\r\n\r\n  echo\r\n  echo \"Information of Dmgr Node\"\r\n  su - $WAS_USER ${WAS_ND_HOME}\/bin\/versionInfo.sh\r\n\r\n  echo\r\n  echo \"Information of Update Installer\"\r\n  su - $WAS_USER ${WAS_UPDATE_INSTALLER_HOME}\/bin\/versionInfo.sh\r\n;;\r\n\r\nplugin )\r\n echo \"Regenerating the plugin for the HTTP Server\"\r\n        su - $WAS_USER ${WAS_HOME}\/bin\/GenPluginCfg.sh -cell.name $WAS_CELL -node.name $WAS_NODE_FE\r\n;;\r\n\r\nenv )\r\n $0 status\r\n if [[ \"$?\" = \"1\" ]] then\r\n   for i in $WAS_PROCESSES; do\r\n      echo \"********* $i *********\"\r\n      pid=`ps -ef|grep $i|grep -v grep | awk '{ print $2 }'`\r\n      ps ewww $pid | tr ' ' '\\012' | grep = | sort\r\n      echo\r\n      echo\r\n   done\r\n  else\r\n   echo \"WAS not available, exiting..\"\r\n   exit 1\r\n fi\r\n;;\r\n\r\n* )\r\n echo\r\n echo \"Usage: $0 COMMAND\"\r\n echo \"---------------------------\"\r\n echo \"start         - Start dmgr, node-agent and the application servers\"\r\n echo \"stop          - Stops dmgr, node-agent and the application servers\"\r\n echo\r\n echo \"start-dmgr    - Starts the Deployment Manager\"\r\n echo \"stop-dmgr     - Stops the Deployment Manager\"\r\n echo\r\n echo \"start-node    - Starts the local node-agent\"\r\n echo \"stop-node     - Stops the local node-agent and all appservers\"\r\n echo\r\n echo \"start-all     - starts all application servers\"\r\n echo \"stop-all      - stops all application servers\"\r\n echo\r\n echo \"backup        - Creates online backup of complete cell\"\r\n echo \"restore       - Restores offline backup of complete cell using date YYYYMMDD\"\r\n echo\r\n echo \"status        - Server stopped\/started state\"\r\n echo \"plugin        - regenerate webserver plugin\"\r\n echo \"info          - Show server configuration\"\r\n echo \"env           - Shows environment variables set for WebSphere configuration\"\r\n echo\r\n exit 1\r\nesac<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/ksh # # Set you environment here [ACC,FOP,PRD] ENV=FOP # Set your company name here COMP=WARMETAL # # APP_HOME setting APP_HOME=\/opt\/sft\/${COMP}-${ENV} # Change here the WAS userid, WAS group and sid if necessary WAS_USER=wasuser WAS_GROUP=wasgroup WAS_PROCESSES=&#8221;dmgr nodeagent Front_Server Security_Server APP_Server JMS_Server&#8221; WAS_CELL=&#8221;${COMP}-${ENV}.cell&#8221; WAS_NODE_EB=&#8221;${COMP}-${ENV}.AppSrv.node&#8221; WAS_NODE_FE=&#8221;${COMP}-${ENV}.AppSrv.node&#8221; # Change the location of the directory in this variable of [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2735"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2735"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions"}],"predecessor-version":[{"id":2737,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2735\/revisions\/2737"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}