|
| 1 | +# MinIO and S3-compatible storage |
| 2 | + |
| 3 | +Percona Backup for MongoDB (PBM) works with both AWS S3 and other S3-compatible storage services. We test S3-compatible storage services with PBM using [MinIO :octicons-link-external-16:](https://min.io/) |
| 4 | + |
| 5 | +This document provides an overview of MinIO as the closest S3-compatible storage. To use the native AWS S3 service, see [AWS S3 storage](s3-storage.md). |
| 6 | + |
| 7 | +[Configuration example :material-arrow-down:](#configuration-example){.md-button} |
| 8 | + |
| 9 | +## Bucket creation |
| 10 | + |
| 11 | +1. Install a [MinIO client :octicons-link-external-16:](https://min.io/docs/minio/linux/reference/minio-mc.html#install-mc). After the installation, the `mc` is available for you. |
| 12 | + |
| 13 | +2. Configure the `mc` command line tool with a MinIO Server |
| 14 | + |
| 15 | + ```{.bash data-prompt="$"} |
| 16 | + $ mc alias set myminio http://127.0.0.1:9000 MINIO_ACCESS_KEY MINIO_SECRET_KEY |
| 17 | + ``` |
| 18 | + |
| 19 | +3. Create a bucket |
| 20 | + |
| 21 | + ```{.bash data-prompt="$"} |
| 22 | + $ mc mb myminio/my-minio-bucket |
| 23 | + ``` |
| 24 | + |
| 25 | +4. Verify the bucket creation |
| 26 | + |
| 27 | + ```{.bash data-prompt="$"} |
| 28 | + $ mc ls myminio |
| 29 | + ``` |
| 30 | + |
| 31 | +After the bucket is created, apply the proper [permissions for PBM to use the bucket](storage-configuration.md#permissions-setup). |
| 32 | + |
| 33 | +## Configuration example |
| 34 | + |
| 35 | +!!! important |
| 36 | + |
| 37 | + Percona Backup for MongoDB (PBM) needs its own dedicated S3 bucket exclusively for backup-related files. Ensure that this [bucket is created](#bucket-creation) and managed solely by PBM. |
| 38 | + |
| 39 | +This is the example for the basic configuration of MinIO and other S3-compatible storage services in Percona Backup for MongoDB. You can find [the configuration file template :octicons-link-external-16:](https://github.com/percona/percona-backup-mongodb/blob/v{{release}}/packaging/conf/pbm-conf-reference.yml) and uncomment the required fields. |
| 40 | + |
| 41 | +```yaml |
| 42 | +storage: |
| 43 | + type: minio |
| 44 | + minio: |
| 45 | + endpoint: localhost:9100 |
| 46 | + bucket: pbm-example |
| 47 | + prefix: data/pbm/test |
| 48 | + credentials: |
| 49 | + access-key-id: <your-access-key-id-here> |
| 50 | + secret-access-key: <your-secret-key-here> |
| 51 | +``` |
| 52 | + |
| 53 | +For the description of configuration options, see [Configuration file options](../reference/configuration-options.md). |
| 54 | + |
| 55 | +## Fine-tune storage configuration |
| 56 | + |
| 57 | +The following sections describe how you can fine-tune your storage configuration: |
| 58 | + |
| 59 | +* [debug logging](#debug-logging) |
| 60 | +* [upload retries](#upload-retries) |
| 61 | +* [data upload to storage with self-signed TLS certificates](#data-upload-to-storage-with-self-signed-tls-certificates) |
| 62 | +* [multiple endpoints to the same S3 storage](endpoint-map.md) |
| 63 | + |
| 64 | +### Debug logging |
| 65 | + |
| 66 | +You can enable debug logging for different types of storage requests in Percona Backup for MongoDB. Percona Backup for MongoDB prints log messages in the `pbm logs` output so that you can debug and diagnose storage request issues or failures. |
| 67 | + |
| 68 | +To enable debug logging, set the `storage.minio.debugTrace` option in Percona Backup for MongoDB configuration. This instructs PBM to also print HTTP trace from the MinIO storage in the logs. |
| 69 | + |
| 70 | +## Upload retries |
| 71 | + |
| 72 | +You can set up the number of attempts for Percona Backup for MongoDB to upload data to S3 storage. Set the `storage.minio.retryer.numMaxRetries` option in Percona Backup for MongoDB configuration. |
| 73 | + |
| 74 | +```yaml |
| 75 | +retryer: |
| 76 | + numMaxRetries: 3 |
| 77 | +``` |
| 78 | + |
| 79 | +This upload retry increases the chances of data upload completion in cases of unstable connection. |
| 80 | + |
| 81 | +## Data upload to storage with self-signed TLS certificates |
| 82 | + |
| 83 | +Percona Backup for MongoDB supports data upload to S3-compatible storage service over HTTPS with a self-signed or a private CA certificate. This feature is especially important when you use services like MinIO, Ceph, or internal S3 gateways that don't use certificates signed by public Certificate Authorities (CAs). |
| 84 | +
|
| 85 | +Providing a whole chain of certificates is recommended to ensure the connection is legit. The `SSL_CERT_FILE` environment variable specifies the path to a custom certificate chain file in PEM-format that PBM uses to validate TLS/SSL connection. |
| 86 | +
|
| 87 | +### Usage example |
| 88 | +
|
| 89 | +Let's assume that your custom CA certificate is at `/etc/ssl/minio-ca.crt` path and your S3 endpoint is `https://minio.internal.local:9000`. To use self-issued TLS certificates, do the following: |
| 90 | + |
| 91 | +1. Ensure the cert file is in PEM format. Use the following command to check it: |
| 92 | + |
| 93 | + ```bash |
| 94 | + cat /etc/ssl/minio-ca.crt |
| 95 | + ``` |
| 96 | + |
| 97 | + ??? example "Sample output" |
| 98 | + |
| 99 | + |
| 100 | + ```{text .no-copy} |
| 101 | + -----BEGIN CERTIFICATE----- |
| 102 | + MIIC+TCCAeGgAwIBAgIJANH3WljB... |
| 103 | + -----END CERTIFICATE----- |
| 104 | + ``` |
| 105 | + |
| 106 | +2. Set the `SSL_CERT_FILE` environment variable to that file's path on each host where `pbm-agent` and PBM CLI are running: |
| 107 | +
|
| 108 | + ```{.bash data-prompt="$"} |
| 109 | + $ export SSL_CERT_FILE=/etc/ssl/minio-ca.crt |
| 110 | + ``` |
| 111 | +
|
| 112 | + If this variable isn't set, PBM uses the system root certificates. |
| 113 | + |
| 114 | +3. Restart `pbm-agent`: |
| 115 | + |
| 116 | + ```{.bash data-prompt="$"} |
| 117 | + $ sudo systemctl start pbm-agent |
| 118 | + ``` |
| 119 | + |
| 120 | +4. Verify that your custom certificate is recognized. Check PBM logs for successful storage access. |
| 121 | + |
| 122 | + |
| 123 | +Alternatively, you can turn off the TLS verification of the S3 storage in Percona Backup for MongoDB configuration: |
| 124 | + |
| 125 | +```{.bash data-prompt="$"} |
| 126 | +$ pbm config --set storage.minio.insecureSkipTLSVerify=True |
| 127 | +``` |
| 128 | + |
| 129 | +!!! warning |
| 130 | + |
| 131 | + Use this option with caution as it might leave a hole for man-in-the-middle attacks. |
| 132 | + |
0 commit comments