sp_DatabaseRestore msg 50000 I used Ola's script to backup my database (SQL Server 2017) and now I'm trying to restore it using Brent's sp_DatabaseRestore. Currently trying to do a Full restore only. Here is my code, written according to the web page:

EXEC dbo.sp_DatabaseRestore 
  @Database = 'LOTR_recovery', 
  @BackupPathFull = 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\OlaBackup\MY-PC\LOTR\FULL\', 
  @ContinueLogs = 0, 
  @RunRecovery = 1;


I put the SP on the destination database as well as Ola's scripts. Apart from these two, the database is empty. I am getting the following error:

 Getting default data drive for @MoveDataDrive
 Getting default log drive for @MoveLogDrive
 Setting default data drive for @MoveFilestreamDrive
 @ExistingDBAction 0 so do nothing
 @ContinueLogs set to 0
 Msg 50000, Level 16, State 1, Procedure dbo.CommandExecute, Line 98 [Batch Start Line 0]
 The value for the parameter @Command is not supported.

 Date and time: 2019-01-02 13:18:32
 Command: RESTORE DATABASE [LOTR_recovery] WITH RECOVERY

 Msg 3153, Level 16, State 2, Line 1
 The database is already fully recovered.
 Msg 3013, Level 16, State 1, Line 1
 RESTORE DATABASE is terminating abnormally.
 Outcome: Failed
 Duration: 00:00:00
 Date and time: 2019-01-02 13:18:32


I tried to search for msg 50000 and @command but without success.

In addition, must sp_DatabaseRestore be created on the destination server I want to restore on, in order to work?
The documentation that I can find on this procedure is somewhat incomplete, especially with regards to the meaning of the input parameters.  

The following are some guesses.  

Looking at the output messages in your question and examining the actual stored procedure code, my suspicion is that the database you are attempting the restore already exists.  The stored procedure has a parameter called @ExistingDBAction which seems to control what the procedure is supposed to do if the database already exists.  The default value of this parameter is zero (0), which means do nothing.  You can actually see that in your output.

@ExistingDBAction 0 so do nothing

So, the procedure attempts to restore the backup to an existing database and receives

 Msg 3153, Level 16, State 2, Line 1
 The database is already fully recovered.
 Msg 3013, Level 16, State 1, Line 1
 RESTORE DATABASE is terminating abnormally.
 Outcome: Failed


The procedure apparently accepts values 1, 2 and 3, but the procedure doesn't really have good documentation on exactly what those parameters do.  

Option 1 appears to set the existing database to single user mode.
Option 2 tries to kill all existing connections to the existing database
Option 3 tries to drop the existing database.

I'd suggest running the procedure and include the @ExistingDBAction parameter with a value of 3.  This should kill all existing connections to the database and then attempts to drop it.

You could also run your process under SQL Server Management Studio debug.  Stepping through the stored procedure code may give you additional insight regarding the problems you are encountering.

As far as your last question about 


  must sp_DatabaseRestore be created on the destination server I want to
  restore in order to work?


That does appear to be the case.



I'm also wondering about the original command in your question.  Specifically, the value you gave for the @Database = 'LOTR_recovery'.  According to the documentation for sp_DatabaseRestore, that parameter should specify the source database.  Is that the actual name of the source database.  If you want to give the restored database a different name from the source database, you should include the parameter @RestoreDatabaseName with a value of the restored database name.

These additional points may or may not be of interest.  I just wanted to make sure you were aware of the parameters and their meanings.