04-22-2017 06:12 AM
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
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!
06-29-2017 03:59 AM
@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
11-03-2017 01:37 AM
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?
Explore our Alfresco products with the links below. Use labels to filter content by product module.