mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-25 23:06:22 +00:00
15 lines
405 B
Bash
Executable file
15 lines
405 B
Bash
Executable file
#!/bin/sh
|
|
set -e
|
|
|
|
# Volcar y eliminar todos los access logs de dos días atrás
|
|
date="`dateadd today -1d`"
|
|
file="/srv/http/_storage/${date}.psql.gz"
|
|
test -n "${date}"
|
|
test ! -f "${file}"
|
|
|
|
psql -h postgresql "${DATABASE:-sutty}" sutty <<SQL | gzip > "${file}"
|
|
begin;
|
|
copy (select * from access_logs where created_at < '${date}') to stdout;
|
|
delete from access_logs where created_at < '${date}';
|
|
commit;
|
|
SQL
|