Thursday, February 3, 2011

How to create a Mirror of an NFS Share?

Hi Everyone,

For back-up and restoration purposes the purpose of retiring an old server, I will need to create a perfect mirror image of an NFS share. This mirror is not a simple re-direct, but rather, an exact copy of the contents of an NFS Share (including file-permissions).

I have tried simple tasks, such as copying files as root with the command:

cp -pR /path-to-nfs-share/ /local-directory-to-mirror-nfs-share-contents/

Unfortunately, the command above does not copy all files, as it returns permission denied errors for some of the files and directories it encounters. Thus, to avoid potential permissions issues, I wanted to create a perfect mirror (i.e. preserving all permissions) of the files.

Unfortunately, I can't seem to find much documentation on performing this task. Is this doable?

Thank you.

  • Did you issue the command using sudo so you have elevated privileges?

    Rsync might also work better for something like that.

    I'd caution against considering it a backup, as it's just a copy. Backups protect against corruption issues or deleted files. Making copies is more like protecting availability of resources.

    Phanto : Essentially I want to create a copy so I can retire the server. I was running the command while logged in as `root`. Thus, I don't understand why I was getting permission issues. For that reason, I would like to create a mirror so when I retire the old server, the transition is seamless.
    pauska : Use rsync, and re-initate it the moment before you retire your old server to get fresh data.
    Phanto : I've never actually used `rsync` before. Does it require a server component to be installed? Does it also preserve all file permissions? From what I read about it, it only likes to download diffs. Is there a way to only download whole files such that I could easily just flip a switch and use the new server to host the files instead of the old one?
    Bart Silverstrim : Rsync doesn't need a server component. The best way I've found is to run it tunneled with secure shell, so if you have sshd running on the destination you should be fine. There is a switch for it to preserve permissions. As for "flipping the switch", I don't think you can easily do that with anything that's not designed to do so, as you'd have IP configuration issues, but you would have something close to it. I'm not sure what you mean in hesitating because it only downloads diffs...
    Bart Silverstrim : If the file isn't there, rsync will copy the entire file. If a portion of the file changed (think editing a big graphic or video, for example) AND it's a network copy, not directory to directory copy, it will only transfer the changed parts (which you'd want since it'll go much faster if you're trying to capture changes then shut the machine down).
    Bart Silverstrim : If you're copying the files as root and you're getting a permission error, you need to look at the ownership and permissions on the directory/file in question and see what the problem is. If your user as root has no access then you're going to have problems with most utilities.
    Phanto : Excellent. I have SSH on the server, so I will just need to run the specific command to make this happen. If you can, please post a sample command that would connect via SSH to do this. Thanks!
  • Your permission errors may stem from the fact that the machine you were on mounted the NFS filesystem as your userid rather than root, meaning that you weren't seeing the entire filesystem. Or, possibly the NFS mounts are changing the UID on purpose for different groups.

    rsync -aplxo --delete /nfsmount/ /newmountlocation/
    

    Is probably the best way to do it since you don't want to break userids and if you run into a situation where you need to stop, it'll move only changed files. You can stage it and run this several times and make sure you have a complete copy before decommissioning.

    From karmawhore

0 comments:

Post a Comment