Sunday, January 30, 2011

Backup and restore Dynamics AX application files - made easy

Here is sample code which can be used to automatically copy Dynamics AX application files to an archive. This step is really important if you want to ensure that you safely backup your Application files.
To restore your application, you should copy the application files from the backup to the proper application directory and then start service and compile all objects in the application.
This is the sample batch file which you can run using Task scheduler or any other similar program.
@echo on
for /f “tokens=1,2,3,4* delims=.:/- ” %%i in (‘date /t’) do (
for /f “skip=1 tokens=1-4 delims=/-,().” %%x in (‘echo.^|date’) do (
set weekday=%%i&set month=%%j&set day=%%k&set year=%%l))
REM stop aos service
net stop “Dynamics AX Object Server 5.0$01-XXXXX”
REM maps to folder where backups are stored
net use z: /d /y
net use z: \\Backup
REM creates folder with day and time stamp
cd \
mkdir %weekday%%month%%day%%year%
REM copies app folder to the backup location
XCOPY “c:\Program Files\Microsoft Dynamics AX\50\Application\Appl*.*” z:\%weekday%%month%%day%%year%\app\ /K /O /Y /F /I /E
REM start aos service
net start “Dynamics AX Object Server 5.0$01-XXXXXX”
You should replace the “Dynamics AX Object Server 5.0$01-XXXXX” with your service name.

Post a Comment