2022-04-23 19:28:32 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2022-04-23 22:32:55 +00:00
|
|
|
# Volcar y eliminar todos los access logs de dos días atrás
|
2022-04-27 16:57:33 +00:00
|
|
|
date="`dateadd today -1d`"
|
|
|
|
file="/srv/http/_storage/${date}.psql.gz"
|
|
|
|
test -n "${date}"
|
|
|
|
test ! -f "${file}"
|
2022-04-23 19:28:32 +00:00
|
|
|
|
2022-04-27 16:57:33 +00:00
|
|
|
psql -h postgresql "${DATABASE:-sutty}" sutty <<SQL | gzip > "${file}"
|
2022-04-23 19:28:32 +00:00
|
|
|
begin;
|
|
|
|
copy (select * from access_logs where created_at < '${date}') to stdout;
|
|
|
|
delete from access_logs where created_at < '${date}';
|
|
|
|
commit;
|
|
|
|
SQL
|