AnsweredAssumed Answered

Batch Script : Backup alfresco windows

Question asked by yacinezr on Apr 22, 2017
Latest reply on Nov 3, 2017 by arcubalino

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  

 

 

 

@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!

Attachments

Outcomes