How to create a Joomla 1.5 demo website that refreshes every hour

Quote

Please note that this blog post is outdated and the latest version of this tutorial/post is available at, https://www.jv-extensions.com/blogs/sniranjan/80-creating-a-joomla-demo-website-that-is-recreated-periodically.html

Do you have products… [QUOTE][B]Please note that this blog post is outdated and the latest version of this tutorial/post is available at, [url]https://www.jv-extensions.com/blogs/sniranjan/80-creating-a-joomla-demo-website-that-is-recreated-periodically.html[/url][/B][/QUOTE]

[COLOR=black]
Do you have products [/COLOR][COLOR=black]or[/COLOR][COLOR=black]Joomla[/COLOR][COLOR=black] extensions which you want [/COLOR][COLOR=black]to[/COLOR][COLOR=black] showcase [/COLOR][COLOR=black]to[/COLOR][COLOR=black]your[/COLOR][COLOR=black] customers [/COLOR][COLOR=black]and[/COLOR][COLOR=black]website[/COLOR][COLOR=black] visitors [/COLOR][COLOR=black]using[/COLOR][COLOR=black] a demo that they [/COLOR][COLOR=black]can[/COLOR][COLOR=black] play [/COLOR][COLOR=black]with[/COLOR][COLOR=black] entirely? Or just want [/COLOR][COLOR=black]to[/COLOR][COLOR=black] showcase demo [/COLOR][COLOR=black]of[/COLOR][COLOR=black]Joomla[/COLOR][COLOR=black]for[/COLOR][COLOR=black] prospective customers? [/COLOR]

[COLOR=black]Here is a short tutorial [/COLOR][COLOR=black]of[/COLOR][COLOR=black] how we have managed [/COLOR][COLOR=black]to[/COLOR][COLOR=black] create a demo site [/COLOR][COLOR=black]for[/COLOR][COLOR=black] our products such that [/COLOR][COLOR=black]the[/COLOR][COLOR=black] demo [/COLOR][COLOR=black]website[/COLOR][COLOR=black] is refreshed [/COLOR][COLOR=black]or[/COLOR][COLOR=black] recreated once every hour. The refresh is necessary [/COLOR][COLOR=black]to[/COLOR][COLOR=black] ensure that, [/COLOR][COLOR=black]the[/COLOR][COLOR=black] next set [/COLOR][COLOR=black]of[/COLOR][COLOR=black] visitors, get [/COLOR][COLOR=black]the[/COLOR][COLOR=black] originally created demo configuration [/COLOR][COLOR=black]and[/COLOR][COLOR=black]not[/COLOR][COLOR=black]the[/COLOR][COLOR=black] changes made [/COLOR][COLOR=black]in[/COLOR][COLOR=black]the[/COLOR][COLOR=black] last 1 hour by other visitors. Please feel [/COLOR][COLOR=black]free[/COLOR][COLOR=black]to[/COLOR][COLOR=black] add any other tips [/COLOR][COLOR=black]or[/COLOR][COLOR=black] ideas [/COLOR][COLOR=black]with[/COLOR][COLOR=black] their comments.[/COLOR]

[COLOR=black]Here we assume that we are creating [/COLOR][COLOR=black]the[/COLOR][COLOR=black] demo [/COLOR][COLOR=black]in[/COLOR][COLOR=black] [URL]http://demo.yoursite.com[/URL], which is physically at [I]/home/{user}/public_html/demo[/I] folder [/COLOR][COLOR=black]for[/COLOR][COLOR=black] example.[/COLOR]

[B][COLOR=black]Install [/COLOR][COLOR=black]and[/COLOR][COLOR=black] Configure [/COLOR][COLOR=black]the[/COLOR][COLOR=black] Demo site[/COLOR][/B][COLOR=black]:[/COLOR]
[LIST=1]
[*][COLOR=black]Install [/COLOR][COLOR=black]the[/COLOR][COLOR=black] latest version [/COLOR][COLOR=black]of [/COLOR][COLOR=black]Joomla[/COLOR][COLOR=black] 1.5 [/COLOR][COLOR=black]in [/COLOR][COLOR=black]your[/COLOR][COLOR=black] demo subdomain
[/COLOR]
[*][COLOR=black]Ensure that [/COLOR][COLOR=black]the[/COLOR][COLOR=black] demo [/COLOR][COLOR=black]installation[/COLOR][COLOR=black] is successful by being able [/COLOR][COLOR=black]to[/COLOR][COLOR=black] browse through [/COLOR][COLOR=black]the[/COLOR][COLOR=black] joomla webpages [/COLOR][COLOR=black]in[/COLOR][COLOR=black]your[/COLOR][COLOR=black] demo site [/COLOR][COLOR=black]in [/COLOR][COLOR=black]frontend [/COLOR][COLOR=black]and [/COLOR][COLOR=black]backend
[/COLOR]
[*][COLOR=black]Now install [/COLOR][COLOR=black]your[/COLOR][COLOR=black] extensions at [/COLOR][COLOR=black]backend[/COLOR][COLOR=black] as you would normally do so.
[/COLOR]
[*][COLOR=black]Configure [/COLOR][COLOR=black]your[/COLOR][COLOR=black] extensions [/COLOR][COLOR=black]the[/COLOR][COLOR=black]way[/COLOR][COLOR=black] you want them [/COLOR][COLOR=black]to[/COLOR][COLOR=black] be used as demo. Remember that, [/COLOR][COLOR=black]the[/COLOR][COLOR=black] visitors [/COLOR][COLOR=black]in[/COLOR][COLOR=black]the[/COLOR][COLOR=black] demo are supposed [/COLOR][COLOR=black]to[/COLOR][COLOR=black] be editing [/COLOR][COLOR=black]the[/COLOR][COLOR=black] configuration [/COLOR][COLOR=black]of[/COLOR][COLOR=black]your[/COLOR][COLOR=black] component at [/COLOR][COLOR=black]backend[/COLOR][COLOR=black]and[/COLOR][COLOR=black] play around [/COLOR][COLOR=black]with[/COLOR][COLOR=black] it. So make [/COLOR][COLOR=black]the[/COLOR][COLOR=black] configuration as minimal as possible.
[/COLOR]
[*][COLOR=black]Create [/COLOR][COLOR=black]the[/COLOR][COLOR=black] necessary menu items [/COLOR][COLOR=black]for [/COLOR][COLOR=black]your[/COLOR][COLOR=black] extensions so that [/COLOR][COLOR=black]the[/COLOR][COLOR=black] extensions [/COLOR][COLOR=black]can[/COLOR][COLOR=black] be used from [/COLOR][COLOR=black]frontend[/COLOR][COLOR=black] as well (assuming they are [/COLOR][COLOR=black]components[/COLOR][COLOR=black] that need a menu item) [/COLOR]
[/LIST]
[B][COLOR=black]Secure [/COLOR][COLOR=black]your[/COLOR][COLOR=black] Demo site:[/COLOR][/B]
[LIST=1]
[*][COLOR=black]In [/COLOR][COLOR=black]the[/COLOR][COLOR=black] global configuration, disable FTP
[/COLOR]
[*][COLOR=black]Login [/COLOR][COLOR=black]to[/COLOR][COLOR=black]your[/COLOR][COLOR=black] demo site [/COLOR][COLOR=black]backend[/COLOR][COLOR=black]and[/COLOR][COLOR=black] change [/COLOR][COLOR=black]the[/COLOR][COLOR=black] login username [/COLOR][COLOR=black]of[/COLOR][COLOR=black]the[/COLOR][COLOR=black] Super Administrator account [/COLOR][COLOR=black]to[/COLOR][COLOR=black] something other than [/COLOR][COLOR=black]the[/COLOR][COLOR=black] default “admin”. Also set [/COLOR][COLOR=black]the[/COLOR][COLOR=black] password [/COLOR][COLOR=black]of[/COLOR][COLOR=black]this[/COLOR][COLOR=black] account [/COLOR][COLOR=black]to[/COLOR][COLOR=black] something only you know!
[/COLOR]
[*][COLOR=black]Using [/COLOR][COLOR=black]the[/COLOR][COLOR=black] user manager, create a new user. Ensure that [/COLOR][COLOR=black]the[/COLOR][COLOR=black] new user has a common username such as “admin”. Set [/COLOR][COLOR=black]the[/COLOR][COLOR=black] password [/COLOR][COLOR=black]to[/COLOR][COLOR=black] be “admin”. This account will be used by [/COLOR][COLOR=black]the[/COLOR][COLOR=black] demo visitors [/COLOR][COLOR=black]to[/COLOR][COLOR=black] login [/COLOR][COLOR=black]to[/COLOR][COLOR=black] demo site [/COLOR][COLOR=black]backend
[/COLOR]
[*][COLOR=black]For [/COLOR][COLOR=black]the[/COLOR][COLOR=black] newly created user, set [/COLOR][COLOR=black]the[/COLOR][COLOR=black] group as “Manager”.
[/COLOR]
[*][COLOR=black]Now browse through [/COLOR][COLOR=black]the [/COLOR][COLOR=black]frontend [/COLOR][COLOR=black]and [/COLOR][COLOR=black]backend [/COLOR][COLOR=black]pages [/COLOR][COLOR=black]and[/COLOR][COLOR=black] make sure that everything is fine about [/COLOR][COLOR=black]Joomla [/COLOR][COLOR=black]and [/COLOR][COLOR=black]your[/COLOR][COLOR=black] extensions [/COLOR]
[/LIST]
[B][COLOR=black]Make it ready [/COLOR][COLOR=black]for[/COLOR][COLOR=black] restoration every hour[/COLOR][/B][COLOR=black]:[/COLOR]
[LIST=1]
[*][COLOR=black]Create a new folder by name “demo.restorefrom” [/COLOR][COLOR=black]in[/COLOR][COLOR=black] [I]/home/{user}[/I] folder. Also create a new folder called “demo” under [I]/home/{user}/demo.restorefrom. [/I]Note that they must NOT be under public_html folder.
[/COLOR]
[*][COLOR=black]Using [/COLOR][COLOR=black]the[/COLOR][COLOR=black] control panel [/COLOR][COLOR=black]of[/COLOR][COLOR=black]your[/COLOR][COLOR=black] hosting account [/COLOR][COLOR=black]or[/COLOR][COLOR=black]using[/COLOR][COLOR=black] SSH, just copy [/COLOR][COLOR=black]the[/COLOR][COLOR=black] entire contents [/COLOR][COLOR=black]of[/COLOR][COLOR=black] [I]/home/{user}/public_html/demo[/I] recursively [/COLOR][COLOR=black]to[/COLOR][COLOR=black] [I]/home/{user}/demo.restorefrom[/I][I]/demo[/I] folder
[/COLOR]
[*][COLOR=black]Now [/COLOR][COLOR=black]to[/COLOR][COLOR=black] go phpmyadmin [/COLOR][COLOR=black]and[/COLOR][COLOR=black] take a complete SQL dump [/COLOR][COLOR=black]of[/COLOR][COLOR=black]the[/COLOR][COLOR=black] database tables used by [/COLOR][COLOR=black]the[/COLOR][COLOR=black]Joomla[/COLOR][COLOR=black] demo [/COLOR][COLOR=black]website[/COLOR][COLOR=black]. Note [/COLOR][COLOR=black]the[/COLOR][COLOR=black] database name, mysql username [/COLOR][COLOR=black]and[/COLOR][COLOR=black] mysql password as well.
[/COLOR]
[*][COLOR=black]Upload [/COLOR][COLOR=black]the[/COLOR][COLOR=black] database .sql dump file [/COLOR][COLOR=black]to[/COLOR][COLOR=black] [I]/home/{user}/demo.restorefrom[/I] folder
[/COLOR]
[*][COLOR=black]Create a restore.sh shell script [/COLOR][COLOR=black]with[/COLOR][COLOR=black]the[/COLOR][COLOR=black] following contents[/COLOR]

[CODE]
mysql {database name} -u{mysql username} -p{mysql password}
rm -rf /home/{user}/public_html/demo/*
cp -rf /home/{user}/demo.restorefrom/demo/* /home/{user}/public_html/demo/
[/CODE][I][COLOR=black]
[/COLOR][/I]
[*][COLOR=black]Upload [/COLOR][COLOR=black]the[/COLOR][COLOR=black] restore.sh [/COLOR][COLOR=black]to[/COLOR][COLOR=black] [I]/home/{user}/demo.restorefrom [/I]folder
[/COLOR]
[*][COLOR=black]Go [/COLOR][COLOR=black]to[/COLOR][COLOR=black] cron jobs [/COLOR][COLOR=black]in[/COLOR][COLOR=black] hosting control panel [/COLOR][COLOR=black]and[/COLOR][COLOR=black] add [/COLOR][COLOR=black]the[/COLOR][COLOR=black] following entry [/COLOR][COLOR=black]to[/COLOR][COLOR=black] it. [/COLOR]

[COLOR=black][I]/bin/sh /home/{user}/demo.restorefrom/restore.sh
[/I][/COLOR]
[*][COLOR=black]Configure [/COLOR][COLOR=black]the[/COLOR][COLOR=black] cron entry [/COLOR][COLOR=black]in[/COLOR][COLOR=black] such a [/COLOR][COLOR=black]way[/COLOR][COLOR=black] that [/COLOR][COLOR=black]the[/COLOR][COLOR=black] restore.sh is fired every hour (0 * * * *) [/COLOR]
[/LIST]
[COLOR=black]Thats it! As cron fires [/COLOR][COLOR=black]your[/COLOR][COLOR=black] job every hour, [/COLOR][COLOR=black]the[/COLOR][COLOR=black] restore.sh script will execute [/COLOR][COLOR=black]the[/COLOR][COLOR=black] contents [/COLOR][COLOR=black]of[/COLOR][COLOR=black] database dump file which will remove all existing tables [/COLOR][COLOR=black]and[/COLOR][COLOR=black] recreate them [/COLOR][COLOR=black]in[/COLOR][COLOR=black]the[/COLOR][COLOR=black] demo joomla database. Subsequently it will remove [/COLOR][COLOR=black]the[/COLOR][COLOR=black] contents [/COLOR][COLOR=black]of[/COLOR][COLOR=black]the[/COLOR][COLOR=black] (messy) [/COLOR][COLOR=black]website[/COLOR][COLOR=black]in[/COLOR][COLOR=black] public_html/demo folder [/COLOR][COLOR=black]and[/COLOR][COLOR=black] copy [/COLOR][COLOR=black]the[/COLOR][COLOR=black] original demo files from [/COLOR][COLOR=black]the[/COLOR][COLOR=black] backedup /home/{user}/demo.restorefrom/demo folder. So every hour whatever be [/COLOR][COLOR=black]the[/COLOR][COLOR=black] kind [/COLOR][COLOR=black]of[/COLOR][COLOR=black] mess [/COLOR][COLOR=black]your[/COLOR][COLOR=black] demo [/COLOR][COLOR=black]website[/COLOR][COLOR=black] is [/COLOR][COLOR=black]in[/COLOR][COLOR=black], it will be restored [/COLOR][COLOR=black]to[/COLOR][COLOR=black] a clean configuration [/COLOR][COLOR=black]for[/COLOR][COLOR=black] fresh round [/COLOR][COLOR=black]of[/COLOR][COLOR=black] chaos![/COLOR]

[COLOR=black]Also do [/COLOR][COLOR=black]not[/COLOR][COLOR=black] forget [/COLOR][COLOR=black]to[/COLOR][COLOR=black] replace [/COLOR][COLOR=black]the[/COLOR][COLOR=black] paths, folders [/COLOR][COLOR=black]and[/COLOR][COLOR=black] filenames specific [/COLOR][COLOR=black]to[/COLOR][COLOR=black]your[/COLOR][COLOR=black]installation[/COLOR][COLOR=black]in[/COLOR][COLOR=black] place [/COLOR][COLOR=black]of[/COLOR][COLOR=black] placeholders [/COLOR][COLOR=black]in[/COLOR][COLOR=black]the[/COLOR][COLOR=black]the[/COLOR][COLOR=black] above scripts before use. You may [/COLOR][COLOR=black]also[/COLOR][COLOR=black] wish [/COLOR][COLOR=black]to[/COLOR][COLOR=black] chmod all files [/COLOR][COLOR=black]and[/COLOR][COLOR=black] folders [/COLOR][COLOR=black]to[/COLOR][COLOR=black] 644 [/COLOR][COLOR=black]and[/COLOR][COLOR=black] 755 [/COLOR][COLOR=black]in[/COLOR][COLOR=black]the[/COLOR][COLOR=black] script [/COLOR][COLOR=black]to[/COLOR][COLOR=black] ensure that [/COLOR][COLOR=black]the[/COLOR][COLOR=black] permissions are intact after a restore.[/COLOR]