4

I read the Backup and Restore doc at RavenDB website and tried it in my code.

In the doc we have:

Initiating a backup

When running in embedded mode, all you need is to call the method DocumentDatabase.StartBackup().

The above line of code just won't compile with error:

An object reference is required for the non-static field, method, or property
'Raven.Database.DocumentDatabase.StartBackup(string, bool)'

So I tried this just to test:

new DocumentDatabase(_documentStore.Configuration).
                                               StartBackup(@"~\App_Data\Backup", true);

The code compiles but when the app starts I get this error:

Could not open transactional storage: C:\Project\trunk\MyApp\App_Data\Database\Data

Can someone please share some working code about how can one do a full backup of an online embedded document store? Is it even possible without using RavenDB server?

My only option is doing a manual backup of the database folder?

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480

1 Answers1

4

Leniel, You need to use the StartBackup method on the actual instance that you are running. If you are using the EmbeddableDocumentStore, you need to do:

 embeddableDocumentStore.DocumentDatabase.StartBackup(...);
Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41
  • 1
    Oh I see. Now I know what I was doing wrong. I had the embedded document stored variable declared as `private static IDocumentStore _documentStore;`. I then tried to find the DocumentDatabase member but I couldn't find it. I was scared... hehehe After changing it to `private static EmbeddableDocumentStore _documentStore;` it was just there. Thanks Ayende once again... you're the guy! :-) – Leniel Maccaferri Feb 06 '12 at 14:33
  • Just a follow up Ayende: where should I call StartBackup()? I placed it after `_documentStore.Initialize();` just to test and it created the Backup folder but it contains only 2 folders: IndexDefinitions and Index. The data is not being backup... – Leniel Maccaferri Feb 06 '12 at 14:45
  • Interesting enough after some time I saw that it just created one more folder called new with 3 files: Data, Data.pat and RVN00002.log. Is it everything I need to restore the DB in case of a failure? :) – Leniel Maccaferri Feb 06 '12 at 15:04