1c 8.2 postgresql server backup sql bat windows

Челябинская область

Автор:Dmitriy Altuhov

1c 8.2 postgresql server backup sql bat windows

Имеется сервер ubuntu с установленным сервером 1С и БД Postgresql.
Имеется сервер windows 2008 R2.

Задача. Организовать автоматическое резервное копирование базы 1С из postgresql (с сервера 1С) на сервер Windows 2008 R2. Средствами pg_dump. С сохранением последних 7-и архивов.

@echo off & setLocal EnableDelayedExpansion
for /f "skip=14 tokens=* delims= " %%a in ('dir/b/o-d C:\WORK\backupALL\buhgaltery\*.zip') do (
del "C:\WORK\backupALL\buhgaltery\%%a"
)
for /f "skip=21 tokens=* delims= " %%a in ('dir/b/o-d C:\WORK\backupPG1C\*.backup') do (
del "C:\WORK\backupPG1C\%%a"
)
for /f "tokens=1-2 delims=:" %%a in ('echo %time%') do set hhmm=%%a%%b
for /f "tokens=1-3 delims=." %%D in ('echo %DATE%') do set yyyymmdd=%%F%%E%%D
set BACKUP_FILE=C:\WORK\backupPG1C\UPP_%yyyymmdd%_%hhmm%.backup
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD=password
echo on
"C:\Program Files\PostgreSQL\9.2.4-1.1C\bin\pg_dump.exe" --host server1c --port 5432 --username "postgres" --no-password --format custom --blobs --file %BACKUP_FILE% "upp"
@echo off
set BACKUP_FILE=C:\WORK\backupPG1C\APROIZV_%yyyymmdd%_%hhmm%.backup
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD=password
echo on
"C:\Program Files\PostgreSQL\9.2.4-1.1C\bin\pg_dump.exe" --host server1c --port 5432 --username "postgres" --no-password --format custom --blobs --file %BACKUP_FILE% "aproizv"
@echo off
set BACKUP_FILE=C:\WORK\backupPG1C\7PROIZV_%yyyymmdd%_%hhmm%.backup
echo backup file name is %BACKUP_FILE%
echo on
"c:\Program Files\7-zip\7z.exe" a -t7z -ssw -mx3 -r %BACKUP_FILE% D:\share\1CBases
@echo off

Comments Are Closed!!!