#!/bin/sh set -e test -n "$1" # Volcar y eliminar todos los access logs de dos días atrás date="`dateadd today -1d`" file="`realpath $0 | xargs dirname `/../_storage/$1-${date}.psql.gz" test -n "${date}" test ! -s "${file}" psql -h postgresql "${DATABASE:-sutty}" sutty < "${file}" begin; copy (select * from $1 where created_at < '${date}') to stdout; delete from $1 where created_at < '${date}'; commit; SQL