Resetting a local Alfresco installation

Alfresco-Community-3.3 includes a couple of batch files to reset a local Alfresco installation by dropping the database, deleting the data directory and then recreating them. The scripts in question are:
<ALFRESCO INSTALL DIR>\extras\databases\mysql\db_remove.bat
<ALFRESCO INSTALL DIR>\extras\databases\mysql\db_setup.bat
The data directory that db_remove.bat removes is <ALFRESCO INSTALL DIR>/alf_data. Thing is, the scripts don’t work. Original scripts are below.

Tear down script.
:: db_remove.bat
@echo off
rem ---------------------------------------
rem MySQL remove DB command
rem ---------------------------------------

echo Deleting Alfresco database and user...
mysql -u root -p < db_remove.sql

echo Deleting indexes...
del /s /q "../../../alf_data"
Set-up script.
:: db_setup.bat
@echo off
rem ---------------------------------------
rem MySQL create DB command
rem ---------------------------------------

echo Creating Alfresco database and user...
mysql -u root -p < db_setup.sql

echo Database prepared.
They don’t work because they assume mysql is in the PATH already. It isn’t for me and I don’t want it to be. Nor do I want to hard-code paths into these files. So, this is how I modified them:

Tear down script.
:: db_remove.bat
@echo off
rem ---------------------------------------
rem MySQL remove DB command
rem ---------------------------------------

set SCRIPT_HOME=%~dps0
cd ..\..\..\mysql\bin

echo Deleting Alfresco database and user...
mysql -u root -p < %SCRIPT_HOME%\db_remove.sql

echo Deleting indexes...
del /s /q "../alf_data"
Set up script.
:: db_setup.bat
@echo off
rem ---------------------------------------
rem MySQL create DB command
rem ---------------------------------------

set SCRIPT_HOME=%~dps0
cd ..\..\..\mysql\bin

echo Creating Alfresco database and user...
mysql -u root -p < %SCRIPT_HOME%\db_setup.sql

echo Database prepared.
Warning: by themselves, these two scripts still aren’t enough to fully reset an Alfresco install. You should also empty out the alfresco webapp of any customisations you have made: <ALFRESCO INSTALL DIR>\tomcat\webapps\alfresco. I am not sure of any really good way to do this yet, other using a backup of that directory, created before you started adding customisations to it.
Also posted this on the Alfresco forum: Scripts to reset Alfresco installation

Popular Posts