neither "backintime -b" nor "backintime --backup-job" work when run by cron

Bug #451268 reported by Christian Morlok
This bug report is a duplicate of:  Bug #441628: BAckintime crash when screen locked. Edit Remove
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Back In Time
Confirmed
High
Unassigned

Bug Description

I use cron to run "backintime -b" (I also tried "backintime --backup-job" but the problem is the same) as a normal user who has write access to the snapshots path. In most cases the backup doesn't work. The systray icon says "Compare with snapshot ..." and the output of backintime is

----------
Back In Time
Version: 0.9.26

Back In Time comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `backintime --license' for details.

INFO: Lock
INFO: Include folders: ['/home/christian']
INFO: Ignore folders: []
INFO: Last snapshots: {}
INFO: [KDE4Plugin.Systray.run]
INFO: Compare with old snapshot: 20091014-113755
Traceback (most recent call last):
  File "/usr/share/backintime/common/backintime.py", line 174, in <module>
    start_app()
  File "/usr/share/backintime/common/backintime.py", line 86, in start_app
    take_snapshot( cfg, True )
  File "/usr/share/backintime/common/backintime.py", line 42, in take_snapshot
    snapshots.Snapshots( cfg ).take_snapshot( force )
  File "/usr/share/backintime/common/snapshots.py", line 421, in take_snapshot
    ret_val = self._take_snapshot( snapshot_id, now, include_folders, ignore_folders, dict, force )
  File "/usr/share/backintime/common/snapshots.py", line 634, in _take_snapshot
    try_cmd = self._execute_output( cmd, self._exec_rsync_compare_callback, prev_snapshot_name )
  File "/usr/share/backintime/common/snapshots.py", line 912, in _execute_output
    line = pipe.readline()
IOError: [Errno 4] Interrupted system call
----------

There remain 2 processes running forever:
1000 20714 0.0 0.0 11520 1312 ? S 15:00 0:00 /bin/sh /usr/bin/backintime -b
1000 20718 0.1 1.6 349204 33332 ? Sl 15:00 0:03 python /usr/share/backintime/common/backintime.py -b

When I run backintime -b manually, it does work (at least I had no case where the same error occured until now).

I have Python 2.6.3 installed.

Revision history for this message
Christian Morlok (christianmorlok) wrote :

I found the problem: my crond runs scripts with /bin/sh. But the external commands backintime uses do not work with sh.

Now I run a two-lined script backup and it works:

----------
#!/bin/bash
export SHELL=/bin/bash
/usr/bin/backintime -b
----------

I think this problem can be fixed by internally overwriting $SHELL or even ignoring it and running the commands directly using bash.

Revision history for this message
Christian Morlok (christianmorlok) wrote :

I correct: this was _not_ the problem. It ran once, an hour later there is the old problem :-(

Revision history for this message
Richard Bailey (rmjb) wrote :

Can you do a fsck on the file system that stores your snapshots?

Revision history for this message
Christian Morlok (christianmorlok) wrote :

No problem:
$ e2fsck /dev/mapper/backup
e2fsck 1.41.9 (22-Aug-2009)
BACKUP: clean, 27987/127512 files, 323361/509980 blocks
$ e2fsck -f /dev/mapper/backup
e2fsck 1.41.9 (22-Aug-2009)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
BACKUP: 27987/127512 files (1.3% non-contiguous), 323361/509980 blocks

But I don't think there's a problem with the fs. Running the script from terminal it works _every_ time, running by cron it works about once out of 3 or 4 tries.

If this helps, here is the script I use (actually the script runs a normal user, thus some things have to run with sudo and I added a check if the fs is already mounted):

#!/bin/bash
BACKUP="/home/christian/backup-luks.img"
KEYFILE="/home/christian/backup.key"
LOOP=`losetup -f`
losetup "$LOOP" "$BACKUP"
cryptsetup -d "$KEYFILE" luksOpen "$LOOP" backup
mkdir /media/backup
e2fsck /dev/mapper/backup
mount /dev/mapper/backup /media/backup
/usr/bin/backintime -b
umount /media/backup
rmdir /media/backup
cryptsetup luksClose backup
losetup -d "$LOOP"
touch "$BACKUP"

Revision history for this message
Peter Mrosek (mrosekp) wrote :

Hi,

I'm using backintime-kde4 (version: 0.9.26) on Kubuntu 9.10.

When clicking the "Take Snapshot" button the GUI says "Compare with snapshot ..." forever and nothing happens at all.

When starting backintime-kde4 from terminal, the application shows the following lines when "Take Snapshot" is clicked:

INFO: Lock
INFO: Include folders: ['/home', '/etc', '/root']
INFO: Ignore folders: []
INFO: Last snapshots: {}
INFO: [KDE4Plugin.Systray.run]
INFO: Compare with old snapshot: 20091030-185328
INFO: [KDE4Plugin.Systray.run] begin loop
Traceback (most recent call last):
  File "/usr/share/backintime/common/backintime.py", line 174, in <module>
    start_app()
  File "/usr/share/backintime/common/backintime.py", line 86, in start_app
    take_snapshot( cfg, True )
  File "/usr/share/backintime/common/backintime.py", line 42, in take_snapshot
    snapshots.Snapshots( cfg ).take_snapshot( force )
  File "/usr/share/backintime/common/snapshots.py", line 424, in take_snapshot
    ret_val = self._take_snapshot( snapshot_id, now, include_folders, ignore_folders, dict, force )
  File "/usr/share/backintime/common/snapshots.py", line 640, in _take_snapshot
    try_cmd = self._execute_output( cmd, self._exec_rsync_compare_callback, prev_snapshot_name )
  File "/usr/share/backintime/common/snapshots.py", line 918, in _execute_output
    line = pipe.readline()
IOError: [Errno 4] Interrupted system call
Back In Time
Version: 0.9.26
------------------

BTW: My python version is 2.6.4.

Revision history for this message
Klaus Wölfel (k-woelfel) wrote :

I have exactly the same problem s Christian. Running backintime from the terminal works every time, in cron it often stucks after [KDE4Plugin.Systray.run] begin loop

Revision history for this message
Klaus Wölfel (k-woelfel) wrote :

I think, it might have something to do with the kde systemtray icon, because when root's cron runs it (and no icon appears) it works every time. Don't think its because of permissions because it also works as user in the terminal.

Changed in backintime:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Jakub Dundalek (dundalek) wrote :

I had this problem as well. After quick googling I found out that they had similar issue in software called Gajim.
Here is explained why is this happening: http://trac.gajim.org/ticket/674#comment:6
They solved it like this: http://trac.gajim.org/attachment/ticket/674/gajim-eintr3.diff

I adapted their to solution to backintime, diff is included as an attachment. I've been using this fix for a few days now and I haven't noticed this problem anymore.

Revision history for this message
Dan (danleweb) wrote :

The problem described here is related to KDE4 version (KDE4Plugin.Systray.run).
The problem described in gajim is related to gnome libs.

Revision history for this message
took (x-info-9) wrote :

Had the same problem with an old system. Thanks to Jakub Dundalek - his patch works fine for me.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.