Skip to Content
Author's profile photo Adam Csaba Goetz

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
  • Compression
  • 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:

  1. 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>”
  2. 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>
  3. 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)


Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Darryl Griffiths
      Darryl Griffiths

      This is really quite neat!  Thanks.
      It would work as a cluster agnostic solution using this method of adjusting the profiles, but you could also use something similar within the cluster to perform this work if you really wanted to (using a pre-start method/hook).

      Just a note, since it's now 2023, SAPCAR (at least 7.22 version) does not have "-F" option any more.
      You will need to use "-X /path/to/file-list-file".
      Place the list of files to exclude into the file:  /path/to/file-list-file
      Must be a list of exact filenames to exclude, "core*" will not work.  So it will need a prior "ls -1 core*   > /path/to/file-list-file" to generate the exclusion list file.  Then once the SAPCAR execution is completed, the exclusion list file will need removing (a bit of a pain).