feat: archive servers.json files
parent
606170e672
commit
bfa61acf31
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
self="$(basename "$0")"
|
||||||
|
|
||||||
|
files_daily=$((24*60/45))
|
||||||
|
# TODO: Increase these for compression ratio
|
||||||
|
# Values are low for test run
|
||||||
|
recent_file_limit=$((files_daily * 2))
|
||||||
|
recent_file_archive_size=$((files_daily))
|
||||||
|
|
||||||
|
archives_dir="cache-lt/archive/servers"
|
||||||
|
base_file_name="$archives_dir/recent/servers.json"
|
||||||
|
num_recent_files=$(/bin/ls -1 $base_file_name* 2>/dev/null | wc -l)
|
||||||
|
if [ "$num_recent_files" -ge "$recent_file_limit" ]; then
|
||||||
|
>&2 echo "$self: recent file limit reached, compressing"
|
||||||
|
/bin/ls -1tr $base_file_name* |
|
||||||
|
head -n "$recent_file_archive_size" |
|
||||||
|
xargs tar cf "$archives_dir/servers.tar" --remove-files
|
||||||
|
fi
|
@ -0,0 +1,22 @@
|
|||||||
|
"output/servers.json" {
|
||||||
|
rotate -1
|
||||||
|
olddir ../cache-lt/archive/servers/recent
|
||||||
|
createolddir 700
|
||||||
|
nocompress
|
||||||
|
dateext
|
||||||
|
dateformat -%Y-%m-%d-%H:%M:%S
|
||||||
|
copy
|
||||||
|
prerotate
|
||||||
|
etc/archives/archive-recent.sh
|
||||||
|
endscript
|
||||||
|
}
|
||||||
|
|
||||||
|
"cache-lt/archive/servers/servers.tar" {
|
||||||
|
rotate -1
|
||||||
|
missingok
|
||||||
|
compress
|
||||||
|
compresscmd /usr/bin/zstd
|
||||||
|
compressext .zst
|
||||||
|
compressoptions -T0 --long -19
|
||||||
|
uncompresscmd /usr/bin/unzstd
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd "$(dirname "$0")" || exit
|
||||||
|
while ! [ -f ".phpenv.php" ]; do cd ..; done
|
||||||
|
logrotate -f -s etc/archives/logrotate.status etc/archives/logrotate.conf
|
@ -0,0 +1,3 @@
|
|||||||
|
logrotate state -- version 2
|
||||||
|
"output/servers.json" 2024-1-21-13:32:41
|
||||||
|
"cache-lt/archive/servers/servers.tar" 2024-1-21-13:0:0
|
Loading…
Reference in New Issue