Hallo everyone,

I'm writing a report about create a backup for a selected database via backupDatabase().

Here is my code:

var g_startTime = new Date();

function main()
{

    var ADB   = ArisData.getActiveDatabase();
    var oFile;
    var oDbAdmin;
    var sPath = "C://Userdata";
    var sFile = "WorkDB_"+getTimeStampAsString();
    Context.setSelectedPath(sPath);
    Context.setSelectedFile(sFile);
    oFile     = new java.io.File(sPath, sFile);
    dbAdmin  = Context.getComponent("ServerAdmin");
    if(dbAdmin.backupDatabase(ADB,oFile)){
             Dialogs.MsgBox("Work DB"+" was backed up on "+new Date());
         }else{
             Dialogs.MsgBox("Work DB"+" could not be backed up on "+new Date());
         }      
    return;
}

function getTimeStampAsString() {
    var date = g_startTime;
    return date.getFullYear() + "_" +
                ((parseInt(date.getMonth())+1)>9 ? '' : '0') + (parseInt(date.getMonth())+1) + "_" +
                (date.getDate()>9 ? '' : '0') + date.getDate() + "_" +
                (date.getHours()>9 ? '' : '0') + date.getHours() + "_" +
                (date.getMinutes()>9 ? '' : '0') + date.getMinutes() + "_" +
                (date.getSeconds()>9 ? '' : '0') + date.getSeconds()
                }
               
main();

 

But somehow the function backupDatabase() always return false. Could anyone give some suggestions?

Thanks a lot.

Tags: ARIS Report Scripting