I asked Mafia Man the other day how I can take a backup on the fly of everything in TM1 so that if I make changes and stuff up, I can easily restore from my backup.
He gave me the following code that is to be inserted in the Prolog tab under Advanced in a Turbo Integrator process. This creates a full archive of a TM1 Model (in this case CXMD) out to a zip file that will not be overwritten the next time the process is run as it is date time stamped in the file name.
#****Begin: Generated Statements***
#****End: Generated Statements****
### Saves all data from memory and sets up the variables
SaveDataAll();
### Assumes that 7-zip is installed at the defined location
sExec = ‘C:Program Files7-Zip-A7za.exe’;
### Defines the target folder for the backup
sBackupDir = ‘C:TM1_Backups’;
### Defines the source folder for the model to be backed up
sDataDir = ‘C:Program FilesIBMCognos ExpressXceleratorCustomTM1DataCXMD’;
### Defines the name to be used for the backup zip file
sFileName = ‘Data ‘ | TIMST(NOW(), ‘Ymd h.i’, 1) | ‘.zip’;
### Defines the arguments to be used with the zip command
sArgs = ‘ a -tzip ‘;
sCommand = sExec | sArgs | ‘”‘ | sBackupDir | sFileName | ‘” “‘ | sDataDir | ‘*”‘;
### Outputs the variables to a text file for debugging
#ASCIIOUTPUT (‘c:debug-save.txt’, sexec, sbackupdir, sdatadir, sfilename, sargs, scommand);
### Creates the zip
EXECUTECOMMAND (sCommand,0);