Autosave of SAP instances’ work folder
Imagine, what if you have a classic or highly available SAP system and it either crashes more than twice or you have to restart it at least two times or due to an issue the HA software does it automatically (a.k.a. switchover or failover)? Well, in this case all the developer traces and logs will be gone including all the important information. These traces and logs are necessary for root cause analysis.
How to overcome the above situation?
I’ve just tested it in one of my test systems and found a way to save these information instead of loosing them.
What to consider before doing anything?
- SAP saves work folder automatically while startup
- No 3rd party tool involved
- Date and time of saving is part of filename
- File system may overflow
- You have to manually delete unnecessary archives later on
- Some delay while startup procedure
You want more?
Follow the white rabbit instructions:
- Check in /usr/sap/<SID>/<instance>/work/sapstart.log what profile is responsible for starting up SAP.
Example: Startup Profile: “/usr/sap/<SID>/SYS/profile/<SID>_D<VEBMGS><NR>_<hostname>”
- Find a suitable Execute_<NR> line entry for this profile where <NR> is a unique, two-digit number in this profile. Increase the highest available Execute_<NR> by one.
- highest available Execute_<NR> entry is: Execute_08 = <command>
- next entry will start therefore with: Execute_09 = <command>
- Add the following line: Execute_<NR> = <command>
Execute_09 = immediate $(DIR_CT_RUN)/SAPCAR -cfi $(DIR_INSTANCE)/work_`date +%Y%m%d_%H%M%S`.SAR -C $(DIR_INSTANCE)/work . -F “core*”
- Execute_09 = immediate executes the command immediately at startup. Check Starting SAP Services by Making an Entry in the Instance Profile – Configuration in the CCMS – SAP Library out.
- $(DIR_CT_RUN)/SAPCAR -cfi $(DIR_INSTANCE)/work_`date +%Y%m%d_%H%M%S`.SAR defines the name of archive file with timestamp and ignores files in use.
- -C $(DIR_INSTANCE)/work . creates an archive with only the files of a directory.
- -F “core*” excludes all core files (which may quite large). -F won’t work with all of SAPCAR releases; run SAPCAR without arguments to get more information about known options.
ls -al /usr/sap/<SID>/<instance>/ | grep -i work
drwxr-xr-x 3 <sid>adm sapsys 12288 Oct 14 15:19 work
-rw-r–r– 1 <sid>adm sapsys 83832120 Oct 14 15:18 work_20151014_151738.SAR
If you have an SAP system on Windows, check Autosave of SAP instances’ work folder (on Windows)