Commit bb0df42f authored by Stephane Crozat's avatar Stephane Crozat Committed by PICHOU Kyâne
Browse files

non tested version

parents
FROM registry.picasoft.net:5000/pica-debian
MAINTAINER stephane.crozat@utc.fr
RUN apt-get update && \
apt-get install -y --no-install-recommends postgresql-client cron && \
apt-get clean && \
ENV CRON_TIME="0 * * * *"
ADD croninit.sh /croninit.sh
ADD psqlcmd.sh /psqlcmd.sh
CMD ["/psqlcmd.sh"]
CMD ["/croninit.sh"]
# postgres-backup
This image delete automatic messages from Mattermost teams
(previous version, only run on "nx1718").
Delete command is run first when container starts and then every hour.
## Usage:
docker run -d \
--env POSTGRES_HOST=postgres.host \
--env POSTGRES_PORT=27017 \
--env POSTGRES_USER=admin \
--env POSTGRES_PASS=password \
## Parameters
POSTGRES_HOST the host/ip of your postgres database
POSTGRES_PORT the port number of your postgres database
POSTGRES_USER the username of your postgres database
POSTGRES_PASS the password of your postgres database
CRON_TIME the interval of cron job to run postgresdump. `0 * * * *` by default, which is every hour
#!/bin/bash
echo "${CRON_TIME} /psqlcmd.sh" > /crontab.conf
crontab /crontab.conf
exec cron -f
#!/bin/bash
[ -z "${POSTGRES_HOST}" ] && { echo "=> POSTGRES_HOST cannot be empty" && exit 1; }
[ -z "${POSTGRES_PORT}" ] && { echo "=> POSTGRES_PORT cannot be empty" && exit 1; }
[ -z "${POSTGRES_USER}" ] && { echo "=> POSTGRES_USER cannot be empty" && exit 1; }
[ -z "${POSTGRES_PASS}" ] && { echo "=> POSTGRES_PASS cannot be empty" && exit 1; }
[ -z "${POSTGRES_DB}" ] && { echo "=> POSTGRES_DB cannot be empty" && exit 1; }
export PGHOST=$POSTGRES_HOST
export PGPORT=$POSTGRES_PORT
export PGDATABASE=$POSTGRES_DB
export PGUSER=$POSTGRES_USER
export PGPASSWORD=$POSTGRES_PASS
SQL_CMD="DELETE FROM posts WHERE id IN (SELECT p.id FROM posts p LEFT JOIN channels c ON p.channelid=c.id LEFT JOIN teams t ON c.teamid=t.id WHERE p.type='system_join_channel')"
psql -c \""${SQL_CMD}"\"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment