Sign inSign up

sgoubaud/backup-postgres-minio

By sgoubaud

Updated 9 months ago

# POSTGRES DUMP TO MINIO This service lets you export your postgres database to minio

Image
0

5.3K

sgoubaud/backup-postgres-minio repository overview

POSTGRES BACKUP TO MINIO

This service lets yourpostgres database to minio

Compatibility

Service can run on :

  • amd64
  • arm64v8

Versions

  • For postgres 12: use tags 12.X
  • For postgres 15: use tags 15.X

Environments Variables

Environments variablesDefaultDescriptionMandatory / Optionnal
MINIO_ACCESS_KEY_ID_FILENoneAccess Key for the buckerMandatory
MINIO_SECRET_ACCESS_KEY_FILENoneSecret Key for the bucketMandatory
MINIO_REGIONNoneMinio RegionMandatory
MINIO_ALIASNoneAlias for the mc co,mandMandatory
MINIO_HOSTNAMENoneHostname of Minio (ex: https://myminio.domain.tld)Mandatory
MINIO_BUCKETNoneName of the bucket for uploading the dumpMandatory
MINIO_TAGSNoneAdd tags for minio (ex: myservice=backup)Optionnal
MINIO_SUBDIRECTORYNoneSubdirectory (For upload to backups/myservice just enter the subdirectory without backup name)Optionnal
MINIO_ATTRIBUTESNoneOptions for minion commandOptionnal
BACKUP_DIRNoneDump directoryMandatory
POSTGRES_HOSTNoneDatabase hostnmaeMandatory
POSTGRES_USERNoneDatabase user (you can use _FILE for the secret)Mandatory
POSTGRES_PASSWDNoneDatabase Password (you can use _FILE for the secret)Mandatory
POSTGRES_DATABASENoneDatabase name (you can use _FILE for the secret)Mandatory
POSTGRES_SPLIT_TABLE_AND_DATAFalseSlip schema and datas in two postgresOptionnal
POSTGRES_EXCLUDE_TABLEEmpty StringExclude export datas from table pattern. Empty String exports all datasOptionnal
POSTGRES_DUMP_FORMATplainFormat to export data. Values : plain, custom, directory, tar (https://www.postgresql.org/docs/current/app-pgdump.html)Optionnal
SCHEDULENoneCron expression for scheduleMandatory

Secrets

You can use secret file for POSTGRES_USER, POSTGRES_PASSWD_FILE, POSTGRES_DATABASE_FILE

Modes

Backup

2 backup modes are available

Cron mode (Default)

You can start the container in cron mode

CLI

docker run -dit -e MINIO_ACCESS_KEY_ID_FILE=$[YOUR_MINIO_ACCESS_KEY_ID_FILE} /
    -e MINIO_SECRET_ACCESS_KEY_FILE=$[YOUR_MINIO_SECRET_ACCESS_KEY_FILE} /
    -e MINIO_REGION=$[YOUR_MINIO_REGION} /
    -e MINIO_ALIAS=$[YOUR_MINIO_ALIAS} /
    -e MINIO_HOSTNAME=$[YOUR_MINIO_HOSTNAMEE} /
    -e MINIO_BUCKET=$[YOUR_MINIO_BUCKET} /
    -e BACKUP_DIR=$[YOUR_BACKUP_DIR} /
    -e POSTGRES_USER=$[YOUR_POSTGRES_USER} /
    -e POSTGRES_HOST=$[YOUR_POSTGRES_HOST} /
    -e POSTGRES_PASSWD=$[YOUR_POSTGRES_PASSWD} /
    -e POSTGRES_DATABASE=$[YOUR_POSTGRES_DATABASE} /
    -e SCHEDULE=$[YOUR_SCHEDULE} /
    sgoubaud/backup-postgres-minio:latest

or

docker run -dit --env-file ./env.file sgoubaud/backup-postgres-minio:latest

Docker compose

  ---
  version: "3.9"

  backup:
    image: sgoubaud/backup-postgres-minio:latest
    networks:
      - your_network # if needed
    volumes:
      - type: volume
        source: data
        target: /my/target/directory # directory or file
        read_only: true # need to be false if you want to restore data
        volume:
          nocopy: true
      - backup:${BACKUP_DIR}
    environment:
      - MINIO_ACCESS_KEY_ID_FILE=/run/secrets/MINIO_BACKUP_ACCESS_KEY_ID
      - MINIO_SECRET_ACCESS_KEY_FILE=/run/secrets/MINIO_BACKUP_SECRET_ACCESS_KEY
      - MINIO_REGION=${MINIO_REGION}
      - MINIO_ALIAS=${MINIO_ALIAS}
      - MINIO_HOSTNAME=${MINIO_HOSTNAME}
      - MINIO_SUBDIRECTORY=${MINIO_SUBDIRECTORY}
      - MINIO_BUCKET=${MINIO_BUCKET}
      - MINIO_TAGS=${MINIO_TAGS}
      - BACKUP_DIR=${BACKUP_DIR}
      - BACKUP_NAME=${BACKUP_NAME}
      - postgres_PATH=${postgres_PATH}
      - SCHEDULE=${SCHEDULE}
    secrets:
      - MINIO_BACKUP_ACCESS_KEY_ID
      - MINIO_BACKUP_SECRET_ACCESS_KEY

secrets:
  MINIO_BACKUP_ACCESS_KEY_ID:
    external :true
  MINIO_BACKUP_SECRET_ACCESS_KEY:
    external :true
Single backup mode
docker run -dit -e MINIO_ACCESS_KEY_ID_FILE=$[YOUR_MINIO_ACCESS_KEY_ID_FILE} /
    -e MINIO_SECRET_ACCESS_KEY_FILE=$[YOUR_MINIO_SECRET_ACCESS_KEY_FILE} /
    -e MINIO_REGION=$[YOUR_MINIO_REGION} /
    -e MINIO_ALIAS=$[YOUR_MINIO_ALIAS} /
    -e MINIO_HOSTNAME=$[YOUR_MINIO_HOSTNAMEE} /
    -e MINIO_BUCKET=$[YOUR_MINIO_BUCKET} /
    -e BACKUP_DIR=$[YOUR_BACKUP_DIR} /
    -e POSTGRES_USER=$[YOUR_POSTGRES_USER} /
    -e POSTGRES_HOST=$[YOUR_POSTGRES_HOST} /
    -e POSTGRES_PASSWD=$[YOUR_POSTGRES_PASSWD} /
    -e POSTGRES_DATABASE=$[YOUR_POSTGRES_DATABASE} /
    -e SCHEDULE=$[YOUR_SCHEDULE} /
    sgoubaud/backup-postgres-minio:latest backup.sh

or

docker run -dit --env-file ./env.file sgoubaud/backup-postgres-minio:latest backup.sh

Tag summary

Content type

Image

Digest

sha256:6c64f57e1

Size

150.8 MB

Last updated

9 months ago

docker pull sgoubaud/backup-postgres-minio