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

18 lines
399 B
Text
Raw 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`"
file="/srv/_storage/$1-${date}.psql.gz"
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