Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"logfile /dev/stdout" doesn't work (reliably) #324

Open
2 tasks done
multi-io opened this issue Apr 9, 2023 · 6 comments
Open
2 tasks done

"logfile /dev/stdout" doesn't work (reliably) #324

multi-io opened this issue Apr 9, 2023 · 6 comments
Labels

Comments

@multi-io
Copy link

multi-io commented Apr 9, 2023

Checklist

  • I'm reporting a bug
  • I've searched the bugtracker for similar issues, including closed ones.

What did you do?

Put "logfile /dev/stdout" in the config to output all logs to stdout

What happened?


rsnapshot encountered an error! The program was invoked with these options:
/usr/bin/rsnapshot -c /rsnapshot.conf sync

ERROR: /rsnapshot.conf on line 128:
ERROR: logfile /dev/stdout - logfile /dev/stdout exists, but is not a file
ERROR: ---------------------------------------------------------------------
ERROR: Errors were found in /rsnapshot.conf,
ERROR: rsnapshot can not continue. If you think an entry looks right, make
ERROR: sure you don't have spaces where only tabs should be.

What did you expect to happen

rsnapshot should work and log to stdout.

My configuration

config_version 1.2
snapshot_root /host/mnt/backup1/testbackup/
no_create_root 1
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
retain daily 2
retain weekly 2
retain monthly 1
verbose 2
loglevel 4
logfile /dev/stdout
lockfile /var/run/rsnapshot.pid
exclude /host/dev/**
exclude /host/mnt/**
exclude /host/media/**
exclude /host/tickhome/**
exclude /host/shares/**
exclude /host/var/chroots/ub1204/sys/**
exclude /host/var/chroots/ub1204/proc/**
exclude /host/dos/**
exclude /host/proc/**
exclude /host/run/**
exclude /host/swapfile*
exclude /host/sys/**
exclude /host/tmp/**
exclude /host/var/lib/docker/overlay2/**
link_dest 1
sync_first 1
backup /host/usr/lib/gnupg/ usrlibgnupg/

Environment

OS: Ubuntu 22.04.2 LTS
Filesystem: ext4

Other information

The test at

elsif ((-e "$value") && (!-f "$value") && (!-p "$value")) {
checks whether the configured logfile, if it exists, is either a regular file or a named pipe, and reports the error above if it's neither. /dev/stdout is usually a symlink to a symlink to a character device representing the terminal (or whatever stdout is redirected to) -- but even the terminal character device still functions perfectly fine as a log output file. I can make it work if I just remove the whole if branch (

rsnapshot/rsnapshot-program.pl

Lines 1429 to 1432 in 87f2c12

elsif ((-e "$value") && (!-f "$value") && (!-p "$value")) {
config_err($file_line_num, "$line - logfile $value exists, but is not a file");
next;
}
). I think this might even be the solution -- it looks like any problem with the log file will be detected around
$result = open(LOG, ">> $config_vars{'logfile'}");
once it tries to log anything.

I think the -p test might follow symlinks automatically and test whatever file/pipe/device they ultimately point to, so it may return 1 (true) if stdout is redirected to a regular file or a pipe, making the configuration work without modifications to the program in that particular case.

@sgpinkus
Copy link
Member

Almost the same output is directed to stdout as to logfile. I can see it's a bit different, but is this not sufficient?

@DrHyde
Copy link
Member

DrHyde commented Apr 15, 2023

Almost the same output is directed to stdout as to logfile. I can see it's a bit different, but is this not sufficient?

That depends on the loglevel and verbose settings. @multi-io if you play around with the verbose config option is that sufficient to get what you want on STDOUT? FWIW I have:

verbose    2
loglevel   4

and while STDOUT just has minimal errors for machines that were down when it tried to take a backup:

----------------------------------------------------------------------------
rsnapshot encountered an error! The program was invoked with these options:
/usr/local/bin/rsnapshot -c /usr/local/etc/rsnapshot.conf daily 
----------------------------------------------------------------------------
ERROR: /usr/local/bin/rsync returned 30 while processing [email protected]:/home/
ERROR: /usr/local/bin/rsync returned 30 while processing [email protected]:/home/
ERROR: /usr/local/bin/rsync returned 30 while processing [email protected]:/home/

there's a lot more detail in the log file.

[2023-04-14T23:00:00] /usr/local/bin/rsnapshot -c /usr/local/etc/rsnapshot.conf daily: started
[2023-04-14T23:00:00] Setting locale to POSIX "C"
[2023-04-14T23:00:00] echo 14960 > /var/run/rsnapshot.pid
[2023-04-14T23:00:00] mv /Volumes/Backup/snapshots/daily.6/ /Volumes/Backup/snapshots/_delete.14960/
[2023-04-14T23:00:00] mv /Volumes/Backup/snapshots/daily.5/ /Volumes/Backup/snapshots/daily.6/
[2023-04-14T23:00:00] mv /Volumes/Backup/snapshots/daily.4/ /Volumes/Backup/snapshots/daily.5/
... and so on ...
[2023-04-15T03:34:51] /usr/local/bin/rsync -aS --delete --numeric-ids --delete-excluded --timeout=300 --exclude=/proc/ --exclude=/dev/ --exclude=/lost+found/ --exclude=/sys/ --rsh=/usr/bin/ssh [email protected]:/home/ /Volumes/Backup/snapshots/daily.0/dev-freebsd.local-home/
[2023-04-15T03:40:52] [Receiver] io timeout after 301 seconds -- exiting
[2023-04-15T03:40:52] rsync error: timeout in data send/receive (code 30) at io.c(200) [Receiver=3.2.7]
[2023-04-15T03:40:52] /usr/local/bin/rsnapshot -c /usr/local/etc/rsnapshot.conf daily: ERROR: /usr/local/bin/rsync returned 30 while processing [email protected]:/home/
...
[2023-04-15T03:52:54] rm -f /var/run/rsnapshot.pid
[2023-04-15T03:52:54] /bin/rm -rf /Volumes/Backup/snapshots/_delete.14960
[2023-04-15T04:17:56] /usr/local/bin/rsnapshot -c /usr/local/etc/rsnapshot.conf daily: ERROR: /usr/local/bin/rsnapshot -c /usr/local/etc/rsnapshot.conf daily: completed, but with some errors

@djk20
Copy link
Member

djk20 commented Apr 16, 2023 via email

@multi-io
Copy link
Author

Well, I'm running rsnapshot in a container and I basically don't want it to write any logfiles at all. It makes more sense to log to stdout, where a logging agent can pick it up.

@DrHyde
Copy link
Member

DrHyde commented Apr 21, 2023

Have you tried just turning up verbose as suggested, and not setting logfile?

@djk20
Copy link
Member

djk20 commented Apr 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants