This project is read-only.

Periodic recipe reset

Topics: Customizing Orchard, Installing Orchard, Writing modules
Oct 22, 2012 at 11:28 AM


I'm trying to setup a demo site in, with public access to both Admins and Editors, I wonder has anyone built a module to do recipe/database resetting? I can't find any on the gallery.

If not, I'd be happy to start working on one, I would use this discussion to find out where/how it could get started:

- Clean site's App_Data (account for tenant demo) to keep only Settings.txt

- Update table prefix incrementally

- Drop tables with old prefix

- Execute setup of the demo recipe

To the team, how does this sound? Anything I may have missed? Do we have any interfaces for App_Data reset available? Any other pointers you could provide would be great.





Oct 22, 2012 at 5:43 PM

That sounds very difficult, and I haven't heard of anything similar.

Oct 22, 2012 at 7:30 PM

We have done that same thing. We do it with a cmdline program that is run from the Windows Task Scheduler. This cmdline tool does an iisreset, then copies the appdata folder over from a backup copy, and resets some stuff in Azure blob storage. For our low-traffic demo site we are just using sql compact, so the appdata folder is enough. However, this approach could be used to run a sql script that dropped and recreated databases, etc.

It works pretty well and was easy to write.

We did it with an outside tool because it seemed a bit awkward to be messing with the hosting environment from inside Orchard.

Oct 23, 2012 at 9:50 AM
Edited Oct 23, 2012 at 9:50 AM

Same here, I'm using the batch to recreate whole site during the development. Similar script I've been using to recreate a demo site each night.


if %web_root%=="" exit
set asqlcmd="c:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.exe"

cd %web_root%\bin
set app_data=%web_root%\App_Data
del /q %app_data%\*.*
rd /q /s %app_data%\Dependencies
rd /q /s %app_data%\Logs
rd /q /s %app_data%\RecipeQueue
rd /q /s %app_data%\Sites

%asqlcmd% -Q"drop database orchard"
%asqlcmd% -Q"create database orchard"
%asqlcmd% -Q"use orchard; CREATE USER [user] FOR LOGIN [user]"
%asqlcmd% -Q"use orchard; EXEC sp_addrolemember N'db_owner', N'user'"

::orchard setup /SiteName:test /AdminUsername:admin /AdminPassword:123qweQWE /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=localhost;Initial Catalog=orchard;Persist Security Info=True;User ID=user;Password=password"
orchard setup /SiteName:test /AdminUsername:admin /AdminPassword:123qweQWE /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=localhost;Initial Catalog=orchard;Persist Security Info=True;User ID=user;Password=password" /Recipe:Development

Oct 24, 2012 at 12:49 PM
Edited Oct 24, 2012 at 12:49 PM

Very cool, many thanks nswenson and ikutsin I have been inspired by your input :)

@ikutsin, that issreset might make my host provider pull their hairs out! So I'll have to come up with a different way to stop the app pool. But nevertheless many thanks for the code snippet.

I shall keep this thread updated.

Oct 24, 2012 at 6:22 PM

Right, better to recycle specific app pool. :)

Just didn't have that batch with me.