Dump and restore commands for PostgreSQL in Docker

| Comments

Sometimes during development it’s necessary to share the db dump with colleagues. In the previous article i provided the commands for MySQL, here is the same for PostgreSQL.

DATE = $(shell date +%Y-%m-%d)
path ?= .

help: ## show this help
	@echo 'usage: make [target] ...'
	@echo ''
	@echo 'targets:'
	@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*##/#/' | column -t -c 2 -s '#'

dump: ## dump db, usage 'make dump path=/path/to/dumps'
	docker-compose exec --user postgres db pg_dumpall --clean | gzip > $(path)/project-$(DATE).sql.gz

restore: ## restore db from dump file, usage 'make restore dump=dump.sql.gz'
	docker-compose stop web
	gunzip -c $(dump) | docker exec -i --user postgres `docker-compose ps -q db` psql
	docker-compose start web

StackOverflow changes from 2013 to 2017

| Comments

Here is an update for StackOverflow statistics for the users with a reputation more than 300. The last measure was made in January 2013.

I almost stopped to answer from the beginning of 2014. At that time I had a reputation around 1600, now it’s 2630.

The number of users growed more than 3 times, but the distribution by reputation is mostly the same.

EuroPython 2017

| Comments

This year, as in previous, I missed the conference. This time I even bought the ticket, but had to return it. The refund process works well, but takes time. Fortunately, there are the live streams from all days, the only problem is to find a time to watch them.

How to install pillow, psycopg, pylibmc packages in python:alpine image

| Comments

Here is the examples how to install some packages in python:alpine image. Some dependencies should be installed permanently and some only for package build and removed after.

pillow

RUN apk add --no-cache jpeg-dev zlib-dev

psycopg

RUN apk add --no-cache postgresql-dev

pylibmc

RUN apk add --no-cache libmemcached-dev zlib-dev 

Then to install:


RUN apk add --no-cache --virtual .build-deps build-base linux-headers \
    
    && pip3 install pip --upgrade \
    
    && pip3 install <packages list> \
    
    && apk del .build-deps

Mailgun for emails in docker

| Comments

Usually, even a small web application should send some emails: errors, registration, restore password, invitations, etc.

There are 3 solutions:

  • use an existing account, like gmail: the main problem - you don’t know how many emails you can send before being marked as spam
  • use own mail server: need to install, configure and support
  • use email service, like sendgrid, mailgun: easy to configure, provide statistics and logs, can use default http port.

For some my small projects i choosed mailgun, it provides 10000 emails in month for free, for my needs it’s more than enough and after that it’s also not expensive. For django there is a email backend django-mailgun and it takes two minutes to switch to it.

« 9/13 »