74 lines
2.2 KiB
Batchfile
74 lines
2.2 KiB
Batchfile
@echo off
|
|
|
|
REM This script performs a backup of key data in the Docker Compose Alfresco
|
|
REM environment that is started using the companion `docker-compose.yml`
|
|
REM file. It backs up the binary data and database. It ignores the search
|
|
REM engine and MQ server. This is not proper for a production environment.
|
|
|
|
REM Notice that we are not compressing any of this backup. We are counting on
|
|
REM Git's ability to only deal with differences to get far better effective
|
|
REM compression over of the data as it is verioned. Git also compresses these
|
|
REM files in transit and in storage anyway. By not putting them in ZIP files, we
|
|
REM use just as little disk space with one commit and probably 90% smaller over
|
|
REM 10 commits and 99% smaller over 100 commits.
|
|
|
|
call :prepare
|
|
call :backup
|
|
|
|
exit /B 0
|
|
|
|
:prepare
|
|
echo Preparing for the backup ...
|
|
|
|
set THISDIR_REL=%~dp0
|
|
set THISDIR=%THISDIR_REL:~0,-1%
|
|
set DOCKER_COMPOSE_DIR=%THISDIR%
|
|
set DATA_DIR=%DOCKER_COMPOSE_DIR%\data
|
|
|
|
echo Clearing previous backup (if one exists) ...
|
|
rd /s /q "%DATA_DIR%"
|
|
md "%DATA_DIR%"
|
|
|
|
exit /B
|
|
|
|
:backup
|
|
echo Performing a backup ...
|
|
exit /B
|
|
|
|
:backup_database
|
|
set CONTAINER_ID=%1
|
|
set SQL_SCHEMA_FILENAME=%2
|
|
set SQL_DATA_FILENAME=%3
|
|
set DB_NAME=%4
|
|
set DB_USERNAME=%5
|
|
set DB_DISPLAY=%6
|
|
|
|
echo Backing up the %DB_DISPLAY% database ...
|
|
|
|
echo Dumping %DB_DISPLAY% database schema ...
|
|
docker container exec %CONTAINER_ID% pg_dump -U %DB_USERNAME% -s -f /tmp/%SQL_SCHEMA_FILENAME% %DB_NAME%
|
|
|
|
echo Dumping %DB_DISPLAY% database data ...
|
|
docker container exec %CONTAINER_ID% pg_dump -U %DB_USERNAME% -a -f /tmp/%SQL_DATA_FILENAME% %DB_NAME%
|
|
|
|
echo Copying %DB_DISPLAY% database schema from Docker container ...
|
|
docker cp %CONTAINER_ID%:/tmp/%SQL_SCHEMA_FILENAME% "%DOCKER_COMPOSE_DIR%\data"
|
|
|
|
echo Copying %DB_DISPLAY% database data from Docker container ...
|
|
docker cp %CONTAINER_ID%:/tmp/%SQL_DATA_FILENAME% "%DOCKER_COMPOSE_DIR%\data"
|
|
|
|
exit /B
|
|
|
|
:backup_binaryData
|
|
set CONTAINER_ID=%1
|
|
set DATA_DIRECTORY=%2
|
|
set CONTAINER_PATH=%3
|
|
set DISPLAY=%4
|
|
|
|
echo Backing up the %DISPLAY% binary data ...
|
|
|
|
echo Copying %DISPLAY% binary data ...
|
|
docker cp "%CONTAINER_ID%:%CONTAINER_PATH%\%DATA_DIRECTORY%" "%DOCKER_COMPOSE_DIR%\data"
|
|
|
|
exit /B
|