Skip to content

Instantly share code, notes, and snippets.

View olegbuevich's full-sized avatar

Aleh Buyevich olegbuevich

View GitHub Profile
@olegbuevich
olegbuevich / postgres
Last active September 29, 2016 20:36 — forked from mmrwoods/postgres
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database \"{}\";"'
# based on: http://www.php2python.com/wiki/function.imap-utf7-encode/
def modified_base64(s):
s_utf7 = s.encode('utf-7') #
aaa = s_utf7[1:-1].decode().replace('/', ',') # rfc2060
return aaa
def modified_unbase64(s):
s_utf7 = '+' + s.replace(',', '/') + '-'