Powershell Backup and Restore

214 views
Skip to first unread message

br...@jonessolutions.com

unread,
Jun 11, 2018, 3:52:48 PM6/11/18
to RavenDB - 2nd generation document database
I am working on a powershell script to back up and restore a DB I got the backup working but the restore is tougher. I have to delete the database and I have not found anything about that in the documentation.

Can I delete a DB or stop it so it can be restored from PS?

Thanks

Wallace Turner

unread,
Jun 12, 2018, 2:51:47 AM6/12/18
to RavenDB - 2nd generation document database
You can issue an HTTP DELETE to delete all the documents:


curl -X DELETE http://localhost:8080/databases/TestDb/bulk_docs/Raven/DocumentsByEntityName


replace 'TestDb' with your db name. you will have to find a way to do this in powershell but one quick google will reveal the answer i am sure

And for the import you will need Raven.Smuggler (download the raven tools) then you can do

Raven.Smuggler in http://localhost:8080 TestDb.ravendump --database=TestDb


Brian Jones

unread,
Jun 13, 2018, 12:16:00 PM6/13/18
to rav...@googlegroups.com
OK, so I am not real keen on the above process so I started looking at smuggler seems like a way to export and import without the stopping and deleting of the database.

However doing a full export took almost 10 hours so that is not reasonable, I am trying to use the operate-on aspect but it is responding oddly, something is just not quite right with my cmd but I can not see it.

Raven.Smuggler.exe out http://RemoteServer:8080  Database.ravendump --database=Database --operate-on-types=Indexes,Documents --negative-metadata-filter:@id=Raven/Replication/Destinations

output to PS is:
Reading batch of  64 indexes, read so far:         64
Done with reading indexes, total: 64

Not sure what I am missing here any assistance is appreciated


--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/h9FOjxvgdIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Brian Jones
Founder JonesSolutions
ToastMasters Area 25 Director

Brian Jones

unread,
Jun 13, 2018, 1:23:52 PM6/13/18
to rav...@googlegroups.com
if I remove indexes from the types the documents will export nothing I have tried other than the full dump which I can not use is working.

Oren Eini (Ayende Rahien)

unread,
Jun 13, 2018, 2:46:27 PM6/13/18
to ravendb
Backup is _much_ faster, but restore require a clean break.
You can restore to a different database name.

What is it that you are trying to do?

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Brian Jones

unread,
Jun 13, 2018, 4:03:43 PM6/13/18
to rav...@googlegroups.com
i need to set up DR and replication did not work (lost data) in the past and the customer is not willing to try again

So I need to back up\export the prod db move the files to the DR server and then restore

I would like to be able to do this via a scheduled task
I can do the back up but when it comes to restoring I am blocked without manual intervention

I can not find a way to stop or disconnect the DB from the server so I can clean the folder and apply the backup restoring to a new DB will still require some sort of config change 

I am playing with RavenSmugglerAPi right now and it is not magically (just saying a cut and paste from the web is not working) working either so I am trying to debug its issues

open for solution suggestions

I am about ready to extend back to business time by having to restore the DB at disaster time.

Thanks for your help


Oren Eini (Ayende Rahien)

unread,
Jun 14, 2018, 3:31:38 AM6/14/18
to ravendb
The easiest way to do that, given that you need to do this on a continuous basis is:

br...@jonessolutions.com

unread,
Jun 14, 2018, 5:56:47 PM6/14/18
to RavenDB - 2nd generation document database
Where can I find more information on this feature. I have not had any luck, I got smuggler to dump the data but the smuggler import is throwing an error without any any usable information and trying to import by command line is also not working.

I am very frustrated by how difficult it is to back up and restore these databases and the lack of documentation and examples that work.

Smuggler API:
StackTrace "   at Raven.Abstractions.Smuggler.SmugglerDatabaseApiBase.<ImportData>d__35.MoveNext()\r\n   
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   
at Raven.Smuggler.SmugglerDatabaseApi.<ImportData>d__6.MoveNext()\r\n   
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n  
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   
at RavenDR.Program.<runimport>d__1.MoveNext() in D:\\TFS\\IFAA\\RavenDR\\RavenDR\\Program.cs:line 42" string

Command line
D:\BackUpTool\Smuggler>Raven.Smuggler.exe in http://localhost:8080 "D:\RavenDR\d
ump.raven" --database=DatabaseName

Wrote 3,250 [9,118 kb] (total 74,114) documents to server gzipped to 1,145 kb in
 24.3 sec.
Done with reading documents, total: 74103
Begin reading attachments
Done with reading attachments, total: 0
Begin reading indexes
A task was canceled.
 StatusCode: 503, ReasonPhrase: 'Service Unavailable', Version: 1.1, Content: <n
ull>, Headers:
{
}

Any assistance would be appreciated.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Brian Jones
Founder JonesSolutions
ToastMasters Area 25 Director

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/h9FOjxvgdIY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Brian Jones
Founder JonesSolutions
ToastMasters Area 25 Director

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Arkadiusz Palinski

unread,
Jun 15, 2018, 3:01:47 AM6/15/18
to rav...@googlegroups.com
Regarding the server smuggling feature. You can run it thought the studio (Manage Your Server -> Server Smuggling):


In addition, there is `Show curl` button here that will return `curl` command which you can use in your script.
Reply all
Reply to author
Forward
0 new messages