TM1 Backup via TI

Post Reply
appleglaze28
Regular Participant
Posts: 269
Joined: Tue Apr 21, 2009 3:43 am
OLAP Product: Cognos TM1, Planning
Version: 9.1 SP3 9.4 MR1 FP1 9.5
Excel Version: 2003

TM1 Backup via TI

Post 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);
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: TM1 Backup via TI

Post 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 :)
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
lotsaram
MVP
Posts: 3698
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: TM1 Backup via TI

Post 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.
Alan Kirk
Site Admin
Posts: 6645
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: TM1 Backup via TI

Post 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".
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
User avatar
Steve Rowe
Site Admin
Posts: 2455
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: TM1 Backup via TI

Post 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
Technical Director
www.infocat.co.uk
Post Reply