Batch Script : Backup alfresco windows

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Batch Script : Backup alfresco windows

hello,
I'm posting my script (.bat) to help peaple to backup alfresco
you must configure the first 7 line of this script with your alfresco installation 
"cwrsync.zip" contains rsync.exe that will synchronise alfresco contentstore with the mirror contententstore

you can configure the windows "Task Scheduler" to run this script when ever you want 
I wish that my script help you Smiley Happy 

@ECHO OFF

REM  zribi.yacine@gmail.com

SET BACKUP_DIR=C:\Users\YZ\Desktop\BACKUPALF
SET ALF_DATA_PATH=D:\alfresco-community1
SET ALF_DATA_DIR_NAME=alf_data
SET DATABASE_NAME=alfresco
SET RSYNC=C:\cwrsync\bin\rsync.exe
SET Postgresql_Port=5432
Set Postgresql_DB_name=alfresco

REM +-----------------------------------------------------------------------+
REM | Do not change anything below here unless you know what you are doing. |
REM +-----------------------------------------------------------------------+


md %BACKUP_DIR%\DB_BACKUPS
SET POSTGRESQLDUMP=%ALF_DATA_PATH%\postgresql\bin\pg_dump.exe
SET STORE=%BACKUP_DIR:~0,1%\%BACKUP_DIR:~3%\STORE
SET contentstore-deleted=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\contentstore.deleted
SET contentstore=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\contentstore


cd %ALF_DATA_PATH%\%ALF_DATA_DIR_NAME%

ECHO Backing up the alfresco Postgresql database...
timeout /t 10
call %POSTGRESQLDUMP% --host 127.0.0.1 --port %Postgresql_Port% --username "postgres" --no-password --format tar --blobs --verbose --file "%BACKUP_DIR%\DB_BACKUPS\%DATE:~3,2%-%DATE:~0,2%-%DATE:~6,4% T %TIME:~0,2%-%TIME:~3,2%.backup" "%Postgresql_DB_name%"

echo %TIME:~0,2%-%TIME:~3,2%

ECHO Syncronisation "contentstore"...
timeout /t 10
%RSYNC% --delete -a -v "/cygdrive/%contentstore:\=/%" "/cygdrive/%STORE:\=/%"
%RSYNC% --delete -a -v "/cygdrive/%contentstore-deleted:\=/%" "/cygdrive/%STORE:\=/%"

ECHO Finished!

2 Replies
Highlighted
Active Member

Re: Batch Script : Backup alfresco windows

@ECHO OFF

SET BACKUP_DIR=C:\Users\infouser\Documents\BACKUPALF\alf_data
SET ALF_DATA_PATH=C:\alfresco-community
SET ALF_DATA_DIR_NAME=alf_data
SET DATABASE_NAME=alfresco
SET RSYNC=C:\cwrsync\bin\rsync.exe
SET Postgresql_Port=5432
Set Postgresql_DB_name=alfresco

REM +-----------------------------------------------------------------------+
REM | Do not change anything below here unless you know what you are doing. |
REM +-----------------------------------------------------------------------+


md %BACKUP_DIR%\DB_BACKUPS
SET POSTGRESQLDUMP=%ALF_DATA_PATH%\postgresql\bin\pg_dump.exe
SET STORE=%BACKUP_DIR:~0,1%\%BACKUP_DIR:~3%\STORE
SET contentstore-deleted=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\contentstore.deleted
SET contentstore=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\contentstore
SET keystore=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\keystore
SET oouser=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\oouser
SET postgresql=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\postgresql
SET solr4=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\solr4
SET solr4Backup=%ALF_DATA_PATH:~0,1%\%ALF_DATA_PATH:~3%\%ALF_DATA_DIR_NAME%\solr4Backup


cd %ALF_DATA_PATH%\%ALF_DATA_DIR_NAME%

ECHO Backing up the alfresco Postgresql database...
timeout /t 5
call %POSTGRESQLDUMP% --host 127.0.0.1 --port %Postgresql_Port% --username "postgres" --no-password --format tar --blobs --verbose --file "%BACKUP_DIR%\DB_BACKUPS\%DATE:~3,2%-%DATE:~0,2%-%DATE:~6,4% T %TIME:~0,2%-%TIME:~3,2%.backup" "%Postgresql_DB_name%"

echo %TIME:~0,2%-%TIME:~3,2%

ECHO Syncronisation "contentstore"...
timeout /t 5
%RSYNC% --delete -a -v "/cygdrive/%contentstore:\=/%" "/cygdrive/%STORE:\=/%"
%RSYNC% --delete -a -v "/cygdrive/%contentstore-deleted:\=/%" "/cygdrive/%STORE:\=/%"
%RSYNC% --delete -a -v "/cygdrive/%keystore:\=/%" "/cygdrive/%STORE:\=/%"
%RSYNC% --delete -a -v "/cygdrive/%oouser:\=/%" "/cygdrive/%STORE:\=/%"
%RSYNC% --delete -a -v "/cygdrive/%postgresql:\=/%" "/cygdrive/%STORE:\=/%"
%RSYNC% --delete -a -v "/cygdrive/%solr4:\=/%" "/cygdrive/%STORE:\=/%"
%RSYNC% --delete -a -v "/cygdrive/%solr4Backup:\=/%" "/cygdrive/%STORE:\=/%"


ECHO Finished!

This is the right code for complete alf_data backup

Highlighted
Member II

Re: Batch Script : Backup alfresco windows

Hi Rajiv B my credentials for postgresql is alfresco and it has a password, may i know where to put the password in the code?