Rsync gives “chown <…> failed: Invalid argument (22)” with nfs share

backupnfsrsync

I'm trying to back up my entire system to an external disk using rsync, via a shell script which is run as root:

#!/bin/bash
rsync -vSHPhhaX --numeric-ids --delete --exclude-from=/home/rena/.scripts/exclude-list / /home/rena/video/.backup/>/home/rena/video/.backup.log

This script is running on the machine "akira". Originally, /home/rena/video was a USB hard disk attached directly to akira, and the script worked fine.

Recently I moved the disk; now it's mounted at the same path on another machine "yuki", and shared via NFS. So akira:/home/rena/video still refers to the same USB hard disk, only now it's attached to yuki and shared via nfs, instead of attached to akira directly. The disk is using ext3 and encrypted with Truecrypt.

yuki's /etc/exports is:

/home/rena  akira(rw,subtree_check,nohide,no_root_squash) rei(rw,subtree_check,nohide,no_root_squash)
/home/rena/video    akira(rw,subtree_check,nohide,no_root_squash) rei(rw,subtree_check,nohide,no_root_squash)

Now rsync gives an error for every file:

rsync: chown "/home/rena/video/.backup/boot/System.map-2.6.38-8-generic" failed: Invalid argument (22)

nfs seems to be "squashing" even though it's told not to?

rena@akira $ stat /home/rena/video/.backup/boot/abi-2.6.38-10-generic
  File: `/home/rena/video/.backup/boot/abi-2.6.38-10-generic'
  Size: 730457          Blocks: 1440       IO Block: 65536  regular file
Device: 19h/25d Inode: 38822526    Links: 1
Access: (0644/-rw-r--r--)  Uid: (65534/  nobody)   Gid: (65534/ nogroup)
Access: 2011-10-19 22:17:12.000000000 -0600
Modify: 2011-06-28 13:19:43.000000000 -0600
Change: 2011-10-19 22:17:12.000000000 -0600

rena@yuki $ stat /home/rena/video/.backup/boot/abi-2.6.38-10-generic
  File: `/home/rena/video/.backup/boot/abi-2.6.38-10-generic'
  Size: 730457      Blocks: 1440       IO Block: 4096   regular file
Device: fc04h/64516d    Inode: 38822526    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-10-19 22:17:12.000000000 -0600
Modify: 2011-06-28 13:19:43.000000000 -0600
Change: 2011-10-19 22:17:12.000000000 -0600

from akira, the UID and GID appear different; maybe the reason for rsync failing?

[edit] In fact it looks like from akira, every file on the share has UID and GID 65534/nobody.

Best Answer

This seems to be a name resolving problem on your nfs-server (yuki).

  1. Make sure the name-resolving is set to files first for hosts in /etc/nsswitch.conf
  2. If there is a /etc/host.conf make sure that the resolving order is set to : order hosts bind
  3. Put the IPs of your clients into /etc/hosts on the NFS-server. Make sure the short name is the first entry after the IP.