Results 1 to 4 of 4

Thread: 12.04 Samba Server Mirroring

  1. #1
    Join Date
    Dec 2011
    Beans
    20

    12.04 Samba Server Mirroring

    Hi, and thanks for taking the time to read this,

    What I have is two virtually identical (hardware wise) Ubuntu servers. I use one of these servers to as a basic Samba file server for our small business, she runs beautifully, let's call her S1. What I would like to do, is to turn our second server, we'll call her S2, into a mirror image of S1. The idea being that if I have some sort of catastrophic failure of S1, I can quickly substitute S2 in her place with only some minor changes, limiting down time. I am thinking that if I can at a minimum mirror all of my samba shares, as well as my smb.conf file I should be able to get S2 standing in in just about no time at all.

    I am attempting to use rsync to accomplish this, but am running around in circles trying to get it working. I am able to ssh from S2 into S1 using key-based login and a sudo level username without any issues, but I can't seem to get rsync to do it's thing. I have read one tutorial after another and am just not getting anywhere. Maybe you can help me find my way...

    Where I am at now, is entering...

    Code:
    rsync -az --super <username>@<S1's IP adress>:/srv/samba/ /srv/samba/
    Results in a lengthy string of errors like this sample...

    Code:
    *** Skipping any contents from this failed directory ***
    rsync: opendir "/srv/samba/proven_programs" failed: Permission denied (13)
    Am I barking up the wrong tree altogether trying to accomplish this in this manner, or am I just making a stupid mistake along the way somewhere?

    Thank you in advance for any help.
    -Dave

  2. #2
    Join Date
    May 2008
    Location
    SoCal
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: 12.04 Samba Server Mirroring

    Who is the user invoking the rsync command? Does that user have permissions to all the files and directories in /srv/samba? I would use the root user (via sudo) to invoke the command to alleviate the permissions problem.
    -BAB1

  3. #3
    Join Date
    Dec 2011
    Beans
    20

    Re: 12.04 Samba Server Mirroring

    Quote Originally Posted by bab1 View Post
    Who is the user invoking the rsync command? Does that user have permissions to all the files and directories in /srv/samba? I would use the root user (via sudo) to invoke the command to alleviate the permissions problem.
    From S2 I am invoking the rsync command as User2. There is an account on S1, User2, and it has been added to the sudo group. The rsync command ssh's to S1 using the account User1, the main root user login of that server.

    Here is a more complete and descriptive c/p of the command...

    Code:
    User2@S2:~$ rsync -az --super User1@<S1 IP>:/srv/samba/ /srv/samba/
    I was thinking that "--super" was forcing root user (via sudo), but perhaps I misunderstood how this is applied when reading the man page.

    I have tried...

    Code:
    User2@S2:~$ sudo rsync -az --super User1@<S1 IP>:/srv/samba/ /srv/samba/
    ...but this requires me to enter my sudo password for S2, which would kill any chance of automation, which is kind of moot anyway as it fails anyway with...

    Code:
    Permission denied (publickey,password).
    rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
    rsync error: unexplained error (code 255) at io.c(605) [Receiver=3.0.9]
    For this to work, to allow sudo over ssh, do I need to allow root logins? From all I have read this would seem inadvisable, but perhaps I am overlooking something. Is there a way to invoke sudo over ssh without the need for entering a password, and while maintaining reasonable security? Automation is a key component of what I am looking for.

    Thanks for the help.

  4. #4
    Join Date
    May 2008
    Location
    SoCal
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: 12.04 Samba Server Mirroring

    Quote Originally Posted by david_robertson View Post
    From S2 I am invoking the rsync command as User2. There is an account on S1, User2, and it has been added to the sudo group. The rsync command ssh's to S1 using the account User1, the main root user login of that server.
    Does the user (User2) have the same UID on both machines. Linux uses the UID, not the username when applying permissions.

    ...

    Code:
    Permission denied (publickey,password).
    rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
    rsync error: unexplained error (code 255) at io.c(605) [Receiver=3.0.9]
    For this to work, to allow sudo over ssh, do I need to allow root logins? From all I have read this would seem inadvisable, but perhaps I am overlooking something.
    The user that rsync runs under needs to have the proper permissions to manipulate the files (move, copy, delete, etc). This can be accomplished by either allowing that user (i.e. user2) the proper permissions (using a common group) or by allowing root ssh logins
    Code:
    rsync -az  root@<S1 IP>:/srv/samba/ /srv/samba/
    There are no absolutes. It is a matter of context. I use key-based ssh root logins on my home network.

    Is there a way to invoke sudo over ssh without the need for entering a password, and while maintaining reasonable security? Automation is a key component of what I am looking for.

    Thanks for the help.
    Sudo requires a password. But running a key-based root login ssh session invoked from rsync is possible as I said.

    In essence you could just restore the shares data from from your backup, and keep a copy of the first machine's smb.conf file on the second machine just as easily. I use rsnapshot (rsync with a perl wrapper) to do just that. From "bare metal" to fully functioning replacement takes about 15 minutes. So if you had "hot spare" host, the time would be only as long as it took for you to restore from the backup. You do have all the data backed up somewhere; right?
    Last edited by bab1; March 21st, 2013 at 08:11 PM.
    -BAB1

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •