From 370cba36502c0af5838b4670083c627cd1459ea2 Mon Sep 17 00:00:00 2001 From: mivirl <> Date: Sat, 1 Jun 2024 22:02:20 -0500 Subject: [PATCH] client: don't transfer rotated and/or empty log files --- src/client.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/client.pl b/src/client.pl index 7b17fba..27b4cac 100644 --- a/src/client.pl +++ b/src/client.pl @@ -57,9 +57,15 @@ sub ns_systemFH { } sub get_files_recursively { - my @dirs = @_; - my @files = ns_system('./busybox', 'find', @dirs, '-type', 'f'); + my ($dir, $includeempty) = @_; + my @extra_args = (); + if (!$includeempty) { + push @extra_args, '-size', '+0'; + } + + my @files = ns_system('./busybox', 'find', $dir, '-type', 'f', @extra_args); map { chomp $_ } @files; + return @files; } @@ -327,6 +333,11 @@ foreach my $logfile (get_files_recursively('/var/log')) { push @binary_logfiles, $logfile; } } +# Filter out some files +@binary_logfiles = grep { ! ( m|/var/log/journal/.+\.journal| || # Binary journal files + # m|/var/log/journal/[0-9a-f]+/[a-z0-9-]+@[0-9a-f-]*\.journal| || # Rotated binary journal files + m|/var/log/.+\.\d\.[gx]z| # Rotated & compressed log files + ) } @binary_logfiles; # These files will be sent once send_file('/etc/crontab'); # Scheduled jobs -- 2.39.5