2.12. Настройка подключения к хранилищу S3 #
pg_probackup3 поддерживает интерфейс S3 для хранения резервных копий. Данные резервного копирования передаются в S3 и обратно без сохранения в промежуточных хранилищах, что устраняет необходимость в большом временном хранилище.
Примечание
Функциональность S3 доступна только при использовании pg_probackup3 с Postgres Pro Enterprise.
Если вы хотите использовать pg_probackup3 с интерфейсом S3, выполните следующие действия:
Создайте для будущих копий в хранилище S3 корзину (bucket) с уникальным и осмысленным именем.
Создайте ключи ACCESS_KEY и SECRET_ACCESS_KEY, которые будут использоваться для безопасного подключения вместо имени и пароля пользователя.
Для взаимодействия pg_probackup3 с сервером S3 задайте переменные окружения, требуемые для подключения к вашему серверу S3. Например:
export PG_PROBACKUP_S3_HOST=127.0.0.1 export PG_PROBACKUP_S3_PORT=9000 export PG_PROBACKUP_S3_REGION=ru-msk export PG_PROBACKUP_S3_BUCKET_NAME=test1 export PG_PROBACKUP_S3_ACCESS_KEY=admin export PG_PROBACKUP_S3_SECRET_ACCESS_KEY=password export PG_PROBACKUP_S3_HTTPS=ON
В качестве альтернативы можно указать параметры сервера S3 в файле конфигурации или с помощью параметров командной строки. За подробностями обратитесь к описанию параметра
--config-fileв разделе Общие параметры, а также к разделу Параметры S3.Если
--s3=minio, стоит указывать параметры сервера S3, как описано в разделе Параметры S3.Можно указать следующие переменные окружения:
PG_PROBACKUP_S3_HOSTАдрес сервера S3. Можно также указать номер порта через двоеточие. Если номер порта не указан в строке адреса, используется значение
PG_PROBACKUP_S3_PORT. Добавляйте двоеточие только при указании номера порта.Например:
export PG_PROBACKUP_S3_PORT=80 export PG_PROBACKUP_S3_HOST="127.0.0.1:9000"
В этом примере для адреса «127.0.0.1» явно указан порт 9000 и он будет использоваться вместо значения 80, указанного в
PG_PROBACKUP_S3_PORT.PG_PROBACKUP_S3_PORTПорт сервера S3.
PG_PROBACKUP_S3_REGIONРегион сервера S3. По умолчанию —
us-east-1.PG_PROBACKUP_S3_BUCKET_NAMEИмя корзины на сервере S3.
PG_PROBACKUP_S3_ACCESS_KEYPG_PROBACKUP_S3_SECRET_ACCESS_KEYКлючи безопасности для доступа к серверу S3.
PG_PROBACKUP_S3_HTTPSКакой протокол использовать. Поддерживаются следующие значения:
ONилиHTTPS— использовать HTTPSИное — использовать HTTP
PG_PROBACKUP_S3_BUFFER_SIZEРазмер буфера чтения/записи для организации связи с S3, в МиБ. По умолчанию —
16.PG_PROBACKUP_S3_RETRIESМаксимальное количество попыток выполнения запроса к S3 в случае сбоя. По умолчанию —
3.PG_PROBACKUP_S3_TIMEOUTМаксимальное время выполнения HTTP-запроса к серверу S3 в секундах. По умолчанию —
300.PG_PROBACKUP_S3_IGNORE_CERT_VERНе проверять сертификат узла и узла-партнёра. По умолчанию:
OFF.PG_PROBACKUP_S3_CA_CERTIFICATEУказать путь к каталогу файла с сертификатом от доверенного центра сертификации (ЦА).
PG_PROBACKUP_S3_CA_PATHУказать каталог, в котором должны храниться сертификаты доверенного ЦС.
PG_PROBACKUP_S3_CLIENT_CERTУстановить клиентский сертификат SSL.
PG_PROBACKUP_S3_CLIENT_KEYУстановить файл закрытого ключа для клиентских сертификатов TLS и SSL.
2.12. Configuring S3 Connection #
pg_probackup3 supports S3 interface for storing backups. Backup data is transferred to and from S3 without saving it in intermediate locations thus eliminating the need of having a large temporary storage.
Note
S3 is available only when pg_probackup3 is used with Postgres Pro Enterprise.
If you are going to use pg_probackup3 with S3 interface, complete the following steps:
Create a bucket with a unique and meaningful name in the S3 storage for you future backups.
Create ACCESS_KEY and SECRET_ACCESS_KEY tokens to be used for secure connectivity instead of your username and password.
For communication between pg_probackup3 and S3 server, set values of environment variables corresponding to your S3 server. For example:
export PG_PROBACKUP_S3_HOST=127.0.0.1 export PG_PROBACKUP_S3_PORT=9000 export PG_PROBACKUP_S3_REGION=ru-msk export PG_PROBACKUP_S3_BUCKET_NAME=test1 export PG_PROBACKUP_S3_ACCESS_KEY=admin export PG_PROBACKUP_S3_SECRET_ACCESS_KEY=password export PG_PROBACKUP_S3_HTTPS=ON
Alternatively, you can provide S3 server settings in the configuration file or by using the command-line options. For more details, refer to the
--config-fileoption in the section Common Options and to the section S3 Options.It makes sense to specify S3 server settings if
--s3=minio, as described in the section S3 Options.The following environment variables can be specified:
PG_PROBACKUP_S3_HOSTAddress of the S3 server. Can include the port number, separated by a colon. If the port number is not specified in a host string, the value of
PG_PROBACKUP_S3_PORTis assumed. Do not add a colon if the port number is not specified.For example:
export PG_PROBACKUP_S3_PORT=80 export PG_PROBACKUP_S3_HOST="127.0.0.1:9000"
In this example, for the “127.0.0.1” address, the port 9000 is explicitly specified and will be used instead of value 80, specified through
PG_PROBACKUP_S3_PORT.PG_PROBACKUP_S3_PORTThe port of the S3 server.
PG_PROBACKUP_S3_REGIONThe region of the S3 server. The default value is
us-east-1.PG_PROBACKUP_S3_BUCKET_NAMEThe name of the bucket on the S3 server.
PG_PROBACKUP_S3_ACCESS_KEYPG_PROBACKUP_S3_SECRET_ACCESS_KEYSecure tokens on the S3 server.
PG_PROBACKUP_S3_HTTPSThe protocol to be used. Possible values:
ONorHTTPS— use HTTPSOther than
ONorHTTPS— use HTTP
PG_PROBACKUP_S3_BUFFER_SIZEThe size of the read/write buffer for communicating with S3, in MiB. The default is
16.PG_PROBACKUP_S3_RETRIESThe maximum number of attempts to execute an S3 request in case of failures. The default is
3.PG_PROBACKUP_S3_TIMEOUTThe maximum amount of time to execute an HTTP request to the S3 server, in seconds. The default is
300.PG_PROBACKUP_S3_IGNORE_CERT_VERDon't verify the certificate host and peer. The default is
OFF.PG_PROBACKUP_S3_CA_CERTIFICATESpecify the path to file with trust Certificate Authority (CA) bundle.
PG_PROBACKUP_S3_CA_PATHSpecify the directory with trust CA certificates.
PG_PROBACKUP_S3_CLIENT_CERTSetup SSL client certificate.
PG_PROBACKUP_S3_CLIENT_KEYSetup private key file for TLS and SSL client certificate.