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

17 lines
428 B
Bash
Executable file

#!/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 <<SQL | gzip > "${file}"
begin;
copy (select * from $1 where created_at < '${date}') to stdout;
delete from $1 where created_at < '${date}';
commit;
SQL