FsyncErrorError

From RdiffBackupWiki

Jump to: navigation, search

Suppose you want to back up a directory on your Linux system to your Windows XP box and you want to do it using Samba to mount the Windows shared directory on your Linux file system. Then

rdiff-backup /home/paul/myMusic /mnt/myWindowBox/backupdir

should work but, in my case at least, fails with this error message:

~[[Errno 16]] Device or resource busy: 
'/mnt/myWindowBox/backupdir/rdiff-backup-data/rdiff-backup.tmp.1'

The cause of the problem seems to be this: before backing up any files, rdiff-backup tries to establish the capabilities of the filesystem you are backing up to. One of the capabilities tested is the filesystem's ability to fsync. However, as part of the test rdiff-backup opens a file in the test directory 'rdiff-backup.tmp.1', throws an exception, then tries to delete 'rdiff-backup.tmp.1' - which it fails to do because of the open file




Before following the below solution, try this instead:

echo 0 > /proc/fs/cifs/LookupCacheEnabled

and remount the Samba share. The above command turns off a CIFS cache that can interfere with rdiff-backup's operation.




The solution is to patch the fsync_local function in

/usr/lib/python2.4/site-packages/rdiff_backup/rpath.py


(the path to rpath.py may be different on your Linux system) as shown below. This will ensure that the open file is closed whether there is an exception or not.

> cvs diff -u
cvs diff: Diffing .
Index: rpath.py
RCS file: /sources/rdiff-backup/rdiff-backup/rdiff_backup/rpath.py,v
retrieving revision 1.99
diff -u -r1.99 rpath.py
--- rpath.py    13 Jan 2006 05:29:47 -0000      1.99
+++ rpath.py    28 Jun 2006 15:34:48 -0000
@@ -1145,7 +1145,11 @@
                assert self.conn is Globals.local_connection
                try:
                        fd = os.open(self.path, os.O_RDONLY)
-                       os.fsync(fd)
+                       try:
+                               os.fsync(fd)
+                       except:
+                               os.close(fd)
+                               raise
                        os.close(fd)
                except OSError, e:
                        if locals().has_key('fd'): os.close(fd)

Another approach, that did succeed in using was this: Create a single large file on the smb partition, and create a reiserfs system in that file, and then mount and use that for storing the rdiff-backup inside that.

Like this:

# Mount smb share
mount -t smbfs -o 'username<code>3Dname,password</code>3Dpass' 
   //server/share /mnt/smbShare/bigfile

# Create a 100MB file (or whatever is appropriate for you)
# to hold the [[ReiserFS]] file system...
dd if<code>3D/dev/zero of</code>3D/mnt/smbShare/bigfile bs<code>3D1M count</code>3D100
dev=3D`losetup -f`
echo $dev
losetup $dev /mnt/smbShare/bigfile
mkreiserfs $dev
losetup -d $dev

# Create mountpoint
mkdir /mnt/rdiff-backup

# Now mount it..
mount -o loop /mnt/smbShare/bigfile /mnt/rdiff-backup

rdiff-backup -yada -yada -yada /mnt/rdiff-backup/destination

Notes:

  1. It looks like the same problems is also mentioned here:

http://katastrophos.net/andre/blog/?p=3D19

Personal tools