Created
April 2, 2019 22:58
-
-
Save zeegin/80f4460ee2e18b62469074c78851ab6e to your computer and use it in GitHub Desktop.
1c postgres maintenance and backup for windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
chcp 65001 > nul | |
set E1C_RAS=localhost:3545 | |
set E1C_RAC=C:\Program Files\1cv8\current\bin\rac.exe | |
set DB_SERVER=localhost:3541 | |
set DB_NAME=1C_DATABASE | |
set DB_USER=1C_ADMINISTRATOR | |
set DB_PWD=1C_PASSWORD | |
set PGUSER=PG_ADMINISTRATOR | |
set PGPASSWORD=PG_PASSWORD | |
set PG_BACKUP_DIR=F:\PG_Backup | |
set DATETIME=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2% %TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2% | |
set DUMPFILE=%DB_NAME% %DATETIME%.backup | |
set DUMPPATH="%PG_BACKUP_DIR%\%DUMPFILE%" | |
echo # Установить блокировку базы и завершить все сеансы | |
call deployka session kill -ras %E1C_RAS% -rac "%E1C_RAC%" -db "%DB_NAME%" -db-user "%DB_USER%" -db-pwd "%DB_PWD%" -lockmessage "Резервное копирование" -lockuccode backup | |
echo # Тестирования и исправления информационной базы: | |
echo - реструктуризация таблиц -Rebuild | |
echo - реиндексация таблиц -ReIndex | |
echo - сжатие таблиц -IBCompression | |
echo - пересчет итогов -RecalcTotals | |
call 1cv8 DESIGNER /S %DB_SERVER% /IBName "%DB_NAME%" /N "%DB_USER%" /P "%DB_PWD%" /IBCheckAndRepair -Rebuild -ReIndex -IBCompression -RecalcTotals /UC backup /DisableStartupMessages /DisableStartupDialogs | |
echo # Очистка и анализ базы данных | |
call vacuumdb --full --analyze --dbname="%DB_NAME%" --username="%PGUSER%" --no-password --echo | |
echo # Реиндексация базы данных | |
call reindexdb --dbname="%DB_NAME%" --username="%PGUSER%" --no-password --echo | |
echo # Резервное копирование | |
call pg_dump --file=%DUMPPATH% --format=custom --blobs --dbname="%DB_NAME%" --username="%PGUSER%" --no-password | |
echo # Снять блокировку базы | |
call deployka session unlock -ras %E1C_RAS% -rac "%E1C_RAC%" -db "%DB_NAME%" -db-user "%DB_USER%" -db-pwd "%DB_PWD%" | |
echo # Удаление старых резервных копий | |
forfiles /p "%PG_BACKUP_DIR%" /S /D -30 /C "cmd /c del /f /a /q @file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
chcp 65001 > nul | |
rem %1 - полный номер версии 1С:Предприятия | |
rem %2 - первые две цифры номеров портов. Для портов 1540,1541,1560:1591 - это цифра 15 | |
set SrvUserName=.\USR1CV8 | |
set SrvUserPwd=1C_WINDOWS_PASSWORD | |
set CtrlPort=%240 | |
set AgentName=localhost | |
set RASPort=%245 | |
set SrvcName="1C:Enterprise 8.3 Remote Server %CtrlPort% %1" | |
set BinPath="\"C:\Program Files\1cv8\%1\bin\ras.exe\" cluster --service --port=%RASPort% %AgentName%:%CtrlPort%" | |
set Desctiption="Cервер администрирования 1С:Предприятия 8.3. Параметры: %1, %CtrlPort%, %RASPort%" | |
sc stop %SrvcName% | |
sc delete %SrvcName% | |
sc create %SrvcName% binPath= %BinPath% start= auto obj= %SrvUserName% password= %SrvUserPwd% displayname= %Desctiption% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
chcp 65001 > nul | |
rem %1 - полный номер версии 1С:Предприятия | |
rem %2 - первые две цифры номеров портов. Для портов 1540,1541,1560:1591 - это цифра 15 | |
rem %3 - каталог с данными реестра кластера | |
set SrvUserName=.\USR1CV8 | |
set SrvUserPwd=1C_WINDOWS_PASSWORD | |
set RangePort=%260:%291 | |
set BasePort=%241 | |
set CtrlPort=%240 | |
set SrvcName="1C:Enterprise 8.3 Server Agent %CtrlPort% %1" | |
set BinPath="\"C:\Program Files\1cv8\%1\bin\ragent.exe\" -srvc -agent -regport %BasePort% -port %CtrlPort% -range %RangePort% -d \"%~3\" -debug" | |
set Desctiption="Агент сервера 1С:Предприятия 8.3. Параметры: %1, %CtrlPort%, %BasePort%, %RangePort%" | |
if not exist "%~3" mkdir "%~3" | |
sc stop %SrvcName% | |
sc delete %SrvcName% | |
sc create %SrvcName% binPath= %BinPath% start= auto obj= %SrvUserName% password= %SrvUserPwd% displayname= %Desctiption% depend= Dnscache/Tcpip/lanmanworkstation/lanmanserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
chcp 65001 > nul | |
rem %1 - полный номер версии 1С:Предприятия | |
rem %2 - первые две цифры номеров портов. Для портов 1540,1541,1560:1591 - это цифра 15 | |
set CtrlPort=%240 | |
set SrvcName="1C:Enterprise 8.3 Remote Server %CtrlPort% %1" | |
sc stop %SrvcName% | |
sc delete %SrvcName% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
chcp 65001 > nul | |
rem %1 - полный номер версии 1С:Предприятия | |
rem %2 - первые две цифры номеров портов. Для портов 1540,1541,1560:1591 - это цифра 15 | |
set SrvcName="1C:Enterprise 8.3 Server Agent %240 %1" | |
sc stop %SrvcName% | |
sc delete %SrvcName% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment