Problem with prefilebackup client side script with background (nohup) process

I discovered that executing prefilebackup script that initiates background process (unattached to prefilebackup script with nohup), waits that unatached process to end before continuing with backup.
Here is simplified pefilabackup script, written here just for demonstration purpose.
This prefilebackup script is blocking backup for 120s, before it continues to run:

# Write start time of initiation of prefilebackup script to file /tmp/prefile.log
echo Started $(date) > /tmp/prefile.log
# Initiate background process unattached to prefilebackup script
nohup sleep 120 & 
# Write time when this script ends
echo Ended  $(date) >> /tmp/prefile.log

Log file that is result of script above shows that whole prefilebackup scripts does not wait 120s:

[root@OEL7_a tmp]# cat /tmp/prefile.log
Started Wed Jan 9 18:52:36 EST 2019
Ended Wed Jan 9 18:52:36 EST 2019

But still, backup starts only after background script ends after 120s. Here is urbackup log file for such backup session:

Level Time Message
Info 9/1/2019 18:52 Starting unscheduled incremental file backup…
Info 9/1/2019 18:54 Backing up “root” without snapshot.
Info 9/1/2019 18:54 Indexing of “root” done. 10027 filesystem lookups 0 db lookups and 0 db updates
Info 9/1/2019 18:54 OEL7_a: Loading file list…
Info 9/1/2019 18:54 OEL7_a: Calculating file tree differences…
Info 9/1/2019 18:54 OEL7_a: Calculating tree difference size…
Info 9/1/2019 18:54 OEL7_a: Linking unchanged and loading new files…
Info 9/1/2019 18:54 Referencing snapshot on “OEL7_a” for path “root” failed: FAILED
Warnings 9/1/2019 18:54 Error getting complete file "8JEilXeXc0NjtStE5CRI
Info 9/1/2019 18:54 Waiting for file transfers…
Info 9/1/2019 18:54 Waiting for file hashing and copying threads…
Warnings 9/1/2019 18:55 Not all folder metadata could be applied. Metadata was inconsistent.
Info 9/1/2019 18:55 Writing new file list…
Info 9/1/2019 18:55 All metadata was present
Info 9/1/2019 18:55 Transferred 15.4031 MB - Average speed: 22.6765 MBit/s
Info 9/1/2019 18:55 Time taken for backing up client OEL7_a: 3m 20s
Info 9/1/2019 18:55 Backup succeeded

Please note that I have tried different timeouts (lower or higher of 120s), and concluded that this prefilebackup script somehow waits ending of background process, that should not be waited at all.

I am testing urbackup server ( UrBackup 2.2.11) with linux clients with version v2.3.4.0.
Client is running on Oracle Enterprise Linux 7 (OEL 7).

Thank you.

Have you tried adding a disown, i.e. nohup sleep 120 & disown?

Yes I tried that with same results.

Does it work if you use setsid instead of nohub?

Same behavior again.
Can you reproduce this problem at your installation?

Thank you

Is this approved defect on any linux platform? Is there any workaround?

Idk, it’s not really a UrBackup problem. UrBackup just uses popen(3) in glibc. You’ll probably have to use the double-fork trick. Or put your background process in a systemd oneshot unit (that way you’d get logging as well).

I’m a very long way from being any bash guru, but didn’t you just background that line with the & it may well background the sleep too & thus your script will continue. Maybe, this is more half-informed guesswork than anything else, what happens when you run the script manually in a terminal?
Does something like:
# Initiate background process unattached to prefilebackup script
nohup &
sleep 120
Do what you’re after? Start the background nohup backgrounded & then sleep the foregrounded prefilebackup script?

Finaly I found solution for the problem (redirection of nohup.out file to /dev/null).
This line is one that does not block the backup process:

nohup setsid sleep 120 >/dev/null 2>&1 &

Thank you all

1 Like

This is why I rarely attempt to help Linux URBackup users, I always seem to make myself look a chump :roll_eyes: