Restart logging after restoring backup

Message ID 20191011184205.30715-1-ipfr@tfitzgeorge.me.uk
State Accepted
Commit 28797d488e51901076a350242c014ff140e58d5f
Headers
Series Restart logging after restoring backup |

Commit Message

Tim FitzGeorge Oct. 11, 2019, 6:42 p.m. UTC
  Send SIGHUP to syslogd and suricata after restoring backup.  This ensures that
if the restored backup includes log files that any new log messages get
appended to the restored log files.  Otherwise they will be written to the
old log files which are pending deletion.

httpd is told to restart using apachectl, which is the equivalent of sending
a signal. 'graceful' (USR1) is used rather than 'restart' (HUP) because the
latter immediately kills the process restoring the backup, preventing
converters from running.

Fixes: 12196
Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
---
 config/backup/backup.pl | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Michael Tremer Oct. 14, 2019, 10:29 a.m. UTC | #1
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>

> On 11 Oct 2019, at 19:42, Tim FitzGeorge <ipfr@tfitzgeorge.me.uk> wrote:
> 
> Send SIGHUP to syslogd and suricata after restoring backup.  This ensures that
> if the restored backup includes log files that any new log messages get
> appended to the restored log files.  Otherwise they will be written to the
> old log files which are pending deletion.
> 
> httpd is told to restart using apachectl, which is the equivalent of sending
> a signal. 'graceful' (USR1) is used rather than 'restart' (HUP) because the
> latter immediately kills the process restoring the backup, preventing
> converters from running.
> 
> Fixes: 12196
> Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
> ---
> config/backup/backup.pl | 5 +++++
> 1 file changed, 5 insertions(+)
> 
> diff --git a/config/backup/backup.pl b/config/backup/backup.pl
> index 6ac4e4967..b1dd1d297 100644
> --- a/config/backup/backup.pl
> +++ b/config/backup/backup.pl
> @@ -71,6 +71,11 @@ restore_backup() {
> 
> 	tar xvzpf "${filename}" -C /
> 
> +	# Restart syslogd, httpd and suricata in case we've just loaded old logs
> +	apachectl -k graceful
> +	/bin/kill -HUP `cat /var/run/suricata.pid 2> /dev/null` 2> /dev/null
> +	/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null
> +
> 	# Run converters
> 
> 	# Outgoing Firewall
> -- 
> 2.16.4
>
  

Patch

diff --git a/config/backup/backup.pl b/config/backup/backup.pl
index 6ac4e4967..b1dd1d297 100644
--- a/config/backup/backup.pl
+++ b/config/backup/backup.pl
@@ -71,6 +71,11 @@  restore_backup() {
 
 	tar xvzpf "${filename}" -C /
 
+	# Restart syslogd, httpd and suricata in case we've just loaded old logs
+	apachectl -k graceful
+	/bin/kill -HUP `cat /var/run/suricata.pid 2> /dev/null` 2> /dev/null
+	/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null
+
 	# Run converters
 
 	# Outgoing Firewall