Author Topic: Automated backup from a database source  (Read 18588 times)

Firedragon

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Automated backup from a database source
« on: December 12, 2011, 09:57:48 pm »
Good morning,

I am trying to write a program in C# that automates the creation of a EAP file from a database EA project. This is in order to create an EAP at a scheduled basis to be able to be stored in our local configuration control system. I offer 2 options, a GUI interface and a command line option

I have managed to work out some of it but it is being a little unstable at times so i could do with some help.

So I use it like the following (obviously with the correct connection details)

Code: [Select]
public bool ExportDatabaseToEAP()
{
      var project = new Project();
      
      string Source = @"DBType=1;Connect=Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=**;Initial Catalog=***;Data Source=***;"
      
      string Target = @"C:\Backup\dump.eap";
      string LogFile = @"C:\Backup\dump.log";
      
      return project.ProjectTransfer(Source, Target, LogFile);
}

Now first question: Can I get easily feedback as to what the dumping process is doing? The tool in EA displays what it is doing, and I can see that the log file is updated as it goes so I could somehow make the updating from there but ideally I don't want to use the log file. It takes a while to transfer the project and it would be good to get feedback if possible

Second question: Once I have dumped the EAP is there a way to automate running of project compare so I can check it is the same as the database?

Third question: This works, but sometimes it gives errors.

Not sure how/if I can upload images on here but what it says is:

"Microsoft OLE DB Provider for SQL Server [-214721900] Incorrect syntax near '`'."

Followed by:

"Source database must be at least version 3.50. Please upgrade source first, then try again"

AnikCadieux

  • EA Novice
  • *
  • Posts: 9
  • Karma: +2/-0
  • Be what you wanna be
    • View Profile
Re: Automated backup from a database source
« Reply #1 on: March 23, 2016, 03:09:30 am »
We get the same error, but every time script is running.
Anyone found anything ?

Thx

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Automated backup from a database source
« Reply #2 on: March 23, 2016, 04:58:47 pm »
Hi,

regarding your SQL error.

In the file %APPDATA%SparxSystem\EA\DBError.txt you see the SQL together with the error. Often this is more helpful than the message.

In my experience there is no reason to check the created database.

Settings of source:
I would check the setting of the existing / running source Repository / (look eg with Repository.ConnectionString). Then I would take these settings. The source has to be a valid EA Repository. You can see tables like t_object in it.

Have you tried with different source Respositories?

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Automated backup from a database source
« Reply #3 on: March 23, 2016, 06:56:46 pm »
If you are backing up the entire repository, you should use the inbuilt Project Transfer API calls.  There is some fiddling but you can create an EAP file quickly, easily and fully supported.

We take our exports twice a day (at least) and it has "saved our bacon" a few times.

If you are interested, I can discuss in more detail.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

AnikCadieux

  • EA Novice
  • *
  • Posts: 9
  • Karma: +2/-0
  • Be what you wanna be
    • View Profile
Re: Automated backup from a database source
« Reply #4 on: March 30, 2016, 06:41:19 am »
Hi,

regarding your SQL error.

In the file %APPDATA%SparxSystem\EA\DBError.txt you see the SQL together with the error. Often this is more helpful than the message.

In my experience there is no reason to check the created database.

Settings of source:
I would check the setting of the existing / running source Repository / (look eg with Repository.ConnectionString). Then I would take these settings. The source has to be a valid EA Repository. You can see tables like t_object in it.

Have you tried with different source Respositories?

Helmut

Thank you Helmut, I didn't know about the existence of  "DBError.txt". It says : Attribut de chaĆ®ne de connexion non valide

Context:
   Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DEV_ENTERPRISE_ARCHITECT_2;Data Source=EArchitect.bd.capitale1dev.local

What is weird is that the connexion string works fine when opening the project or when doing the project Transfer manually. The error only occurs when scripting.
Also, if I add a port number, for example 15001 after the Data Source name, it doesn't give the error, but pops a "password" dialog !

AnikCadieux

  • EA Novice
  • *
  • Posts: 9
  • Karma: +2/-0
  • Be what you wanna be
    • View Profile
Re: Automated backup from a database source
« Reply #5 on: March 30, 2016, 06:46:48 am »
If you are backing up the entire repository, you should use the inbuilt Project Transfer API calls.  There is some fiddling but you can create an EAP file quickly, easily and fully supported.

We take our exports twice a day (at least) and it has "saved our bacon" a few times.

If you are interested, I can discuss in more detail.

HTH,
Paolo

Hello Paolo,

Thank you for your reply.
Are you using the JAVA API dll found in C:\Program Files (x86)\Sparx Systems\EA\Java API ?

We don't want to use Visual Studio so we tried using the Automation module with Eclipse but the ProjectTransfer() function isn't exposed !
 :o

Thank you in advance for giving me more details !  :)
Anik

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Automated backup from a database source
« Reply #6 on: March 30, 2016, 07:38:34 am »
What is weird is that the connexion string works fine when opening the project or when doing the project Transfer manually. The error only occurs when scripting.
Also, if I add a port number, for example 15001 after the Data Source name, it doesn't give the error, but pops a "password" dialog !
This happens if you try to access a non existing data source. EA is really unique in its behavior.

q.

AnikCadieux

  • EA Novice
  • *
  • Posts: 9
  • Karma: +2/-0
  • Be what you wanna be
    • View Profile
Re: Automated backup from a database source
« Reply #7 on: March 30, 2016, 07:47:24 am »
Unique, indeed.
This test prooves EA processes differently the connection string though scripting VS trough File \ Open.
I wish I was a guru like you qwerty :P

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Automated backup from a database source
« Reply #8 on: March 30, 2016, 08:41:42 am »
That also means you need to experience a lot of frustration :-/

q,

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Automated backup from a database source
« Reply #9 on: March 30, 2016, 10:54:32 am »
[SNIP]

Hello Paolo,

Thank you for your reply.
Are you using the JAVA API dll found in C:\Program Files (x86)\Sparx Systems\EA\Java API ?

We don't want to use Visual Studio so we tried using the Automation module with Eclipse but the ProjectTransfer() function isn't exposed !
 :o

Thank you in advance for giving me more details !  :)
Anik
No, we're not using the Java API, so I can't help there.  We're just using the built-in scripting for this purpose.

Once you are able to get and use the Project Transfer function, you need to understand that the API version requires a target EAP file - you can't create one directly.  So, we delete the old backup and copy an empty .eap from over the top of the old backup (principally to ensure the target exists - even if manually deleted previously) and then replace it with the contents of the server.

So there's a bit of fiddling involved, but it works fine.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

AnikCadieux

  • EA Novice
  • *
  • Posts: 9
  • Karma: +2/-0
  • Be what you wanna be
    • View Profile
Re: Automated backup from a database source
« Reply #10 on: March 31, 2016, 04:34:02 am »
Hello Paolo,

How do you call your EA script periodically ? We need this backup to be taken automatically 3-4 times a day.

Thank you,
Anik

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Automated backup from a database source
« Reply #11 on: March 31, 2016, 11:00:47 am »
Hello Paolo,

How do you call your EA script periodically ? We need this backup to be taken automatically 3-4 times a day.

Thank you,
Anik
Hi Anik,

Unfortunately, you can't.  Sparx haven't (as far as I know) provided ANY mechanism to automatically execute a script on product execution.

I'd be happy to be corrected on that.

We use our script as part of a semi-automatic overnight processing mechanism - we use them as "snapshots" of the repository state on a daily basis.  For backup during the day, we just do SQL server backups.  We can recover in about 15-30 mins in the event of a catastrophe.  (Which, of course, BECAUSE we backup; we've never had...  We've had self generated issues - like accidentally deleting 15,000 diagram objects - but we recovered from that mornings snapshot)

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Automated backup from a database source
« Reply #12 on: March 31, 2016, 03:40:04 pm »
Hi,

as far as I know it should be possible to periodically:
- Run a Script from inside an Addin (just make a time event inside your Addin)
  (See Geerts Framework, Class Scripts how to call a Script, it's some work I think)
- Run Code (eg. C#) inside  Addin (just make a time event inside your Addin)
- Run Code from outside EA periodically
  The password to log in may be a security issue

I know software which uses EA as a server from outside to write some information (Update Requirements from MKS/PTC during the night at defined times). User/Password may be a security issue.

Regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Automated backup from a database source
« Reply #13 on: March 31, 2016, 08:21:52 pm »
I would simply set up a scheduler which runs a script that opens EA using the API. Very simple. Works in all circumstances. Also since this script will run with a user that needs to be logged on you can place this in this user's directory where it (as far as Windoze can assure that) will be protected, so a password inside is not a big issue.

q.

AnikCadieux

  • EA Novice
  • *
  • Posts: 9
  • Karma: +2/-0
  • Be what you wanna be
    • View Profile
Re: Automated backup from a database source
« Reply #14 on: April 01, 2016, 12:15:13 am »
Hi all,

We use Eclispse with Java.
We wanted to created a script that would be called by Windows Scheduler or something.
We tried to use the API provided by Sparx, but the "ProjectTransfer()" method is the only method that is not accessible from the outside, it seems private. We are thinking about re-compiling Sparx' dll....

Anyone ever used the ProjectTransfer() method with Java ?

Thanks