Page 1 of 1

TM1 Backup via TI

Posted: Tue Aug 04, 2009 5:41 am
by appleglaze28
Hi I'd like to ask if anybody has done backing up data of TM1 via TI? I acquaintance of mine says she does it by TI...she just gave me the TI process. I'm still not familiar with TI so maybe someone can decipher the script and if it does backup everything or just part of the process. Though as per Alan, he said its proven practice to create a back up just by copying a copy of the data directory.


PROLOG:
DatasourceASCIIDelimiter='';
MDNAME=TIMST(NOW,'\m\d\Y TM1DATA');
ASCIIOUTPUT('E:\TM1BACKUP.BAT','E:');
ASCIIOUTPUT('E:\TM1BACKUP.BAT','CD\');
ASCIIOUTPUT('E:\TM1BACKUP.BAT','MD 10292008TM1DATA');
ASCIIOUTPUT('E:\TM1BACKUP.BAT','COPY "E:\Client Data\ABS\Development\ABS\ABS\*.*" ', 'E:\10292008TM1DATA\');



EPILOG:
EXECUTECOMMAND('E:\TM1BACKUP.BAT',1);

Re: TM1 Backup via TI

Posted: Tue Aug 04, 2009 9:55 am
by Steve Vincent
Interesting way of doing it :)

All its doing is writing a DOS batch file, then executing it at the end.

DatasourceASCIIDelimiter=''; > ensure that no delimiter is used in the file (would normally be a comma)
MDNAME=TIMST(NOW,'\m\d\Y TM1DATA'); > sets a unique name for the directory it will copy the data in to
ASCIIOUTPUT('E:\TM1BACKUP.BAT','E:'); > 1st line of the batch file, change to local drive E
ASCIIOUTPUT('E:\TM1BACKUP.BAT','CD\'); > 2nd line, change to the root directory
ASCIIOUTPUT('E:\TM1BACKUP.BAT','MD 10292008TM1DATA'); > 3rd line, make a directory with the name created by MDNAME*
ASCIIOUTPUT('E:\TM1BACKUP.BAT','COPY "E:\Client Data\ABS\Development\ABS\ABS\*.*" ', 'E:\10292008TM1DATA\'); > copy everything from the E:\Client Data\ABS\Development\ABS\ABS directory in to the one you created*

problem is its not using the MDNAME parameter to pass in to the batch file, its hardcoded to "10292008TM1DATA". Not got time to find out how to do that for ya but i'm sure someone will :)

Re: TM1 Backup via TI

Posted: Tue Aug 04, 2009 10:02 am
by lotsaram
I have to say that's a pretty damn original approach! .... (if not somewhat overly complicated.) The idea of using ASCIIOutput to actually write the batch file had not occurred to me. The more usual option would be to have the batch file(s) sitting in the data directory and pass parameters with ExecuteCommand.

Might look something like this (all code on prolog) ...

Code: Select all

# setup your variables
vTM1Path = 'D:\YourDataDirectory';
vDirBakRoot = 'D:\SomeDirectoryOnYourServer';
vDate = TODAY(1);
vDirBak = vDirBakRoot | '\TM1Bak_' | vDate;
vDOSCmd = 'MkDir.bat ' | vDirBak;

# make time stamped backup directory
ExecuteCommand(vDOSCmd , 1);

# save data all so up to date model is committed to disk (otherwise not much point in backing up :)
SaveDataAll;

# copy the TM1 data directory
vDOSCmd = 'DirCpy.bat ' | vTM1Path | ' ' | vDirBak;
ExecuteCommand(vDOSCmd, 0);
The batch files themselves can be simple one-liners, in this instance "MkDir.bat" need be nothing more than "md %1" and "DirCpy.bat" nothing more than "xcopy %1 %2". Of course you can (and probably should) make the batch files a little more complicated by adding additional parameters.

Alan will probably be along in a second to warn about the evils of using SaveDataAll on some cobweb ridden, unsupported version of TM1, but this shouldn't be an issue for most people.

Re: TM1 Backup via TI

Posted: Tue Aug 04, 2009 6:58 pm
by Alan Kirk
lotsaram wrote: Alan will probably be along in a second to warn about the evils of using SaveDataAll on some cobweb ridden, unsupported version of TM1,
Really? Did you mean 9.1.4? I find it hard to keep track since in the IBM world, "cobweb ridden, unsupported version" seems to mean "most of them".

Re: TM1 Backup via TI

Posted: Thu Aug 27, 2009 1:29 pm
by Steve Rowe
Just to update this thread, I found that I needed to add DatasourceASCIIQuoteCharacter=''; to the prolog to avoid having quotes around my script. It's a very nice way of doing things writing the batch file in the TI itself, +1 to apples mysterious lady friend!

so I get this

Code: Select all

XCopy %1 %2 /R /Y
in my batch file rather than this

Code: Select all

"XCopy %1 %2 /R /Y"
Prolog sample for copying a file

Code: Select all

#Note spaces at the end of the strings so that concatenation produces the correct command line call
SourceFile = '\\starst1p\DataFileShare\Source\Live.txt ';
Destn='\\starst1p\DataFileShare\Destn';
BatchFile='CopyLiveAccess.bat ';

DatasourceASCIIQuoteCharacter='';
#Create the batch file in the data directory

ASCIIOutput ('CopyLiveAccess.bat','XCopy %1 %2 /R /Y');

ExecuteCommand ( BatchFile | SourceFile | Destn, 1);

ASCIIDelete(BatchFile);
Cheers