Updated version for IM r12.6sp2. May be executed on any Windows OS or modified for Unix/Linux.
****
Updated the auto-backup version for IM r12.6sp2; had to adjust the cookie creation lines.
Included the link to the curl version I used on Windows 2008 x64.
http://curl.haxx.se/gknw.net/7.32.0/dist-w32/curl-7.32.0-ssl-sspi-zlib-static-bin-w32.zip
****
@echo on
::Automate daily backup of IME
:: SET DATESTAMP / TIMESTAMP
:: *** Set the date string for file naming and archive ***
for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
set t=%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
if "%t:~0,1%"==" " set t=0%t:~1%
set today=%d:~6,4%%d:~0,2%%d:~3,2%_%t%
:: SET IM OBJECTS
:: Objects below are assumed to have NO space characters
set HOST=imps-001.exchange.exc:8080
set IME=ime
set OID=1
set IMCD=imcd
set IMCD_OID=3
set IMPS=impd
set IMPS_OID=2
:: IM Management Console authentication (r12.6) (if enabled)
set username=idmembedded
set password=Password01
::export HOST OID IME IMCD IMCD_OID IMPS IMPS_OID today
echo HOST=%HOST%
echo OID=%OID%
echo IME=%IME%
echo IMCD=%IMCD% and IMCD_OID=%IMCD_OID%
echo IMPS=%IMPS% and IMPS_OID=%IMPS_OID%
echo today=%today%
del /f cookies
::echo hi > "%today%_%IME%_%IMCD%.txt"
:: Use of open source curl with -o switch to rename output and -c/-b switch to manage the IM Forms of the IM management console
:: Export five of five XML configuration files for IM and the zip file for IME
:: Use this switch to debug --trace-ascii debugdump.txt
:: Use this switch to populate a form --data-urlencode "username=idmembedded"
:: Replace spaces with underscores ${variable// /_}
:: Store Session Cookies for IM Forms
::curl -c cookies
trace-ascii debugdump_auth.txt data-urlencode "username=%username%" --data-urlencode "password=%password%"
http://%HOST%/iam/immanage> nul
::pause
::exit
:: Audit Settings
curl -c cookies
trace-ascii 01_debugdump_audit_listenv.txt data-urlencode "username=%username%" --data-urlencode "password=%password%"
http://%HOST%/iam/immanage/env.do?method=listEnvs > nul
curl -b cookies --trace-ascii 02_debugdump_audit_editenv.txt "http://%HOST%/iam/immanage/env.do?method=editEnv&envoid=%OID%" > nul
curl -b cookies --trace-ascii 03_debugdump_audit_getenv.txt "http://%HOST%/iam/immanage/envsettings.do?method=getSettings&envoid=%OID%&envname=%IME%"> nul
curl -b cookies --trace-ascii 04_debugdump_audit_edititem.txt "http://%HOST%/iam/immanage/audit.do?method=editItem&envname=%IME%&envoid=%OID%" > nul
curl -b cookies -o %today%_%IME%_AuditSettings.xml
trace-ascii 05_debugdump_audit_export.txt data-urlencode "username=%username%" --data-urlencode "password=%password%" "http://%HOST%/iam/immanage/audit.do?method=exportSettings&envoid=%OID%&envname=%IME%"
:: Environmental Settings (IMCD to IMPD)
curl -c cookies
trace-ascii 05_debugdump_audit_listenv.txt data-urlencode "username=%username%" --data-urlencode "password=%password%" "http://%HOST%/iam/immanage/env.do?method=listEnvs" > nul
curl -b cookies --trace-ascii 06_debugdump_audit_editenv.txt "http://%HOST%/iam/immanage/env.do?method=editEnv&envoid=%OID%" > nul
curl -b cookies -o "%today%_%IME%_EnvironmentSettings.xml" --trace-ascii 07_debugdump_audit_exportEnvSet.txt "http://%HOST%/iam/immanage/envsettings.do?method=exportSettings&envoid=%OID%&envname=%IME%"
:: IME Roles/Tasks/Screens/PX Rules/Identity Policies/Mail/Explore&Correlate Definitions
curl -c cookies
trace-ascii 08_debugdump_audit_listenv.txt data-urlencode "username=%username%" --data-urlencode "password=%password%" "http://%HOST%/iam/immanage/env.do?method=listEnvs" > nul
curl -b cookies --trace-ascii 09_debugdump_audit_editenv.txt "http://%HOST%/iam/immanage/env.do?method=editEnv&envoid=%OID%" > nul
curl -b cookies --trace-ascii 10_debugdump_audit_editRole.txt "http://%HOST%/iam/immanage/env.do?method=editRoles&envoid=%OID%&envname=%IME%" > nul
curl -b cookies -o "%today%_%IME%_RoleDefinitions.xml" --trace-ascii 11_debugdump_audit_exportRole.txt "http://%HOST%/iam/immanage/env.do?method=exportRoles&envoid=%OID%&envname=%IME%"
:: Pull IME zip file
curl -c cookies
trace-ascii 12_debugdump_audit_listenv.txt data-urlencode "username=%username%" --data-urlencode "password=%password%" "http://%HOST%/iam/immanage/env.do?method=listEnvs"> nul
curl -b cookies -o "%today%_%IME%.zip" --trace-ascii 13_debugdump_audit_exportime.txt "http://%HOST%/iam/immanage/env.do?method=exportEnv&deleteobjs=,%OID%&envoid=%OID%&envname=%IME%"
:: IMCD User Store
curl -c cookies
trace-ascii 14_debugdump_audit_listdir.txt data-urlencode "username=%username%" --data-urlencode "password=%password%" "http://%HOST%/iam/immanage/dir.do?method=listDirs"> nul
curl -b cookies --trace-ascii 15_debugdump_audit_editdir.txt "http://%HOST%/iam/immanage/dir.do?method=editDir&diroid=%IMCD_OID%"> nul
curl -b cookies -o "%today%_%IMCD%_imcd.xml" --trace-ascii 16_debugdump_audit_exportdir.txt "http://%HOST%/iam/immanage/dir.do?method=exportDir&dirname=%IMCD%"
:: IMPS (IMPD) User Store
curl -c cookies
trace-ascii 17_debugdump_audit_listdir.txt data-urlencode "username=%username%" --data-urlencode "password=%password%" "http://%HOST%/iam/immanage/dir.do?method=listDirs" > nul
curl -b cookies --trace-ascii 18_debugdump_audit_editdir.txt "http://%HOST%/iam/immanage/dir.do?method=editDir&diroid=%IMPS_OID%"> nul
curl -b cookies -o "%today%_%IMPS%_imps.xml" --trace-ascii 19_debugdump_audit_exportdir.txt "http://%HOST%/iam/immanage/dir.do?method=exportDir&dirname=%IMPS%"
:: Remove cookies and debug files after every session
del /f cookies
del /f
debugdump.txt
:: Remove files older than 7 days; to prevent drive from filling up with files.
forfiles /s /m *.xml /d -7 /c "cmd /c del @file"
forfiles /s /m *.zip /d -7 /c "cmd /c del @file"