Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to rsync (backup) a chroot environment from outside the chroot. For that I first make a lvm snapshot of the chroot volume and then run rsync on that.

The only problem with this approach: Symlinks that inside the chroot are absolute are now pointing to the outer-chroot-system and are of course not matching. Since I would like to use copy-unsafe-links, this leads to a false link resolution. Is there a way to make rsync resolve symlinks from another directory than the main root or is there another way to solve this?

share|improve this question
    
so you're trying to copy the file the link points to (-L)? or copy the symlink itself (-l)? –  h3rrmiller Oct 3 '12 at 19:48
    
Neither, I am doing --copy-unsafe-links as stated above. –  Silvia Oct 3 '12 at 20:26
    
No chance with rsync-means. I just played with -R, -l, -k- this does not do what you want. There has to be a chroot-mode for rsync to accomplish what you want. Make a feature-request to the rsync-developers... –  Nils Oct 4 '12 at 9:21

2 Answers 2

You could replace your absolute symlinks with relative ones before doing the rsync.

share|improve this answer
    
Yes, that. This is just one of the ways absolute symlinks cause trouble. The oldie-but-goodie symlinks utility is convenient for that. –  Gilles Oct 4 '12 at 0:04

Changing all absolute symlinks to relative is definitely a good solution, if it can't be done, a convoluted and inefficient way around it that could work is use sshfs that has a --transform_symlinks option to do just that.

You'd need to set a separate ssh server or a user with a separate configuration in the currently running sshd and use a combination of

Subsystem sftp internal-sftp

and

ChrootDirectory /path/to/jail

Now, if you're --copy-unsafe-link and thus don't care to preserve symlinks or save space, you could just run rsync chrooted inside the jail (copy a statically linked rsync there, run nscd, bind-mount /var/run/nscd and exclude both /var/run/nscd and that rsync binary from the sync (you may have to bind-mount /dev and/or proc as well and use --one-file-system))

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.