5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2025-02-23 06:31:48 +00:00
panel/bin/rotate_table

18 lines
428 B
Text
Raw Permalink Normal View History

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