Koozali.org: home of the SME Server

How to syncronise 2 sme servers

Offline torsten

  • *
  • 14
  • +0/-0
    • http://www.deep-sea.net
How to syncronise 2 sme servers
« on: May 24, 2005, 09:09:07 AM »
I would like to have a 2nd sme server which would kick in if the primary server goes down but of course the main thing is that they both have identical data since the last sync.
I know there is rsync but I couldn't get that going and still scratching my head.

Anyone done this before?

Thanks T

arthurhanlon

How to syncronise 2 sme servers
« Reply #1 on: May 24, 2005, 10:13:56 AM »
Hi there,

Would it not be more feasible to look into a mirrored RAID array? Although I have not actually tried it myself, I hear that the software RAID functionality is very good and from what I gather, the hard disk is the most likely thing to "pop" in your server so a mirrored array would probably suffice and save from having two physical boxes.

Just a thought,

Arthur

Offline torsten

  • *
  • 14
  • +0/-0
    • http://www.deep-sea.net
How to syncronise 2 sme servers
« Reply #2 on: May 24, 2005, 10:29:07 AM »
Thanks Arthur,

I was thinking along the same idea...
but as a contingency I thought having a server ready to go would be good.
I had lately a lot of bad luck with my power supply in the servers, not that it is a big deal but takes time to get replaced

T

arthurhanlon

How to syncronise 2 sme servers
« Reply #3 on: May 24, 2005, 11:01:04 AM »
I can appreciate that, my PSU went not so long ago but luckily I had one to hand to replace it with. At the end of the day, I think it all boils down to how critical it is to have your server running.

If you want to go down that path, I would install removable caddies in the servers that way if hardware should fail in one you can just whip out the disk and slot it into the emergency box. No need for the complexity of syncing two physical boxes together. Not sure how well that would work for hardware differences though, maybe someone else can comment?

Again, just a thought,

Arthur  :-)

Offline torsten

  • *
  • 14
  • +0/-0
    • http://www.deep-sea.net
How to syncronise 2 sme servers
« Reply #4 on: May 24, 2005, 12:02:39 PM »
I just found this site
http://www.tech-geeks.org/contrib/loveless/SMEServer/howtos/rsync_backup/SME_BackupServer.html
That might be the solution to the problem...

Offline Morgo

  • *
  • 16
  • +0/-0
How to syncronise 2 sme servers
« Reply #5 on: May 24, 2005, 02:39:23 PM »
Hey Guys,

Mirroring is great for redundancy as you hards will fail, its only a matter of when? Unfortunately raid doesnt help if some low life steals your server (that is usually also a matter of when!). Remember the 3 golden rules of IT - BACKUP, BACKUP AND BACKUP. I would love to here any comments on rsync.

Paul  :-D
Why doesn't anybody sing with an accent  ?????
 and
God Bless Linux ....

Offline torsten

  • *
  • 14
  • +0/-0
    • http://www.deep-sea.net
How to syncronise 2 sme servers
« Reply #6 on: May 24, 2005, 02:52:07 PM »
sure thing Paul you cannot beat backups but that either requires tapes, or like Arthur suggested additional hdd or another syncronised server.
The link to tech-geeks has a good foundation and I will try to modify that to my environment.

Get a primary sme serverwhich does my day to day web serving and emailing
Then I will have a secondary server running and might get them to sync evry hour or so
Once one dies the alarm bells go off and I can quickly action it
Wow that sounds like a plan

T :lol:

Offline chris burnat

  • *****
  • 1,135
  • +2/-0
    • http://www.burnat.com
How to syncronise 2 sme servers
« Reply #7 on: May 24, 2005, 04:09:49 PM »
Torsten, I agree, two boxes are better than one anytime.  Boxes are cheap nowadays, data cannot be replaced easily.  If you do not have time to implement an in-house solution to this problem, you could use dungog rsync and dungog backup. I have a couple of mission critical clients with two identical servers.  (i) configuration files and users are backup from one box to another in tgz format every day.  You may also wish to backup a few essential ibays.  This allow rebuilding a box in a short time.  (ii) Rsync is used to "mirror" ibays from one server (Main) to the other (Standby). Alternatively, essential data such as financial etc can be backed up using Rsync over ssh to an offsite box.  To add some security to this off-site backup scheme, ssh port 22 is changed to a higher port, and password for the rsync operator is made very rugged. Hope it helps. chris.

PS: disk are cheap as well, so do a raid1 on each server.
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #8 on: May 24, 2005, 05:59:39 PM »
I did some experiments on sme backups a for a while ago.

Først I tried to make a routine for automated data backup with a serial number/day system so I just filled a hd no 2 with a series of bacupfiles.

Well it worked, but it filled up with a lot of datas, but my thought around it was this that the bacupdatas were not realy safe, as long as on the same PC.

Then I started to think about a inexpencive storage medium, and I found out that a USB harddisk should be one of the bether choices (??).

Then I started to develop a solution based on the use of the principle of making bacup using a number of cheap USB harddisks for full data backups.

The tasks were automated in such a way that you just had to plug in the usb harddisk for instance in the evening and pick up the full backup in the morning.

This solution were improved until I could not imagine how to improve it more, and then the whole project were packed down, because I really do not use such a backup capacity for my homeserver. The whole project were made mostly for "fun" and the exitement to see if it could work.

I don't know if usb harrdiks is considered to be a "safe enough" medium for backup, but it seems to work rather good. By the way for making it I hacked into the backupfunctions of the sme server to make bacups of the identical same files including dumps from the databases.

What about starting up such a project "backup to the usb harddisk" and then this time with someone with the knowledge of making a server-manager front end ?! (in my project it was just a collection of shell scripts.)

Don't know why USB harddisks are not used a lot as becup media. (Well you could pull out the cable or something but this will normally not happend.)

Arne.
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #9 on: May 24, 2005, 06:46:15 PM »
By the way, one thing I also tried was to syncronize to sme servers using rsync via nework. I could not find out about how to use rsync over the net, so thats the reason that I used rsync to make a data copy to a USB disk.

If someone know some details about how to ser up a rsync server and a rsync client and how to rsync via the network, the principles from the USB backup disc should be quite transferable to a principle of a complete syncronization of to servers.

I had to give up my rsync via net project, but I think it could have worked rather nice, if it had just worked at all. Anybody who knows how to do that ?

Arne.
......

Offline Brenno

  • *****
  • 208
  • +0/-0
How to syncronise 2 sme servers
« Reply #10 on: May 24, 2005, 10:05:59 PM »
I'm with arne on this one... using rsync to backup remote servers would be great.  I can get it working fine on a local network, but never from a remote network.  I'm trying to backup a few Windows servers using openssh and sync2nas.  I'm close, but stumped. It just doesn't work and nothing ever shows up in the SME logs for clues.

Any ideas?

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #11 on: May 24, 2005, 11:43:39 PM »
At the moment I must admit that I do not understand the info contained in this link, but I believe it might have some interesing content ..

http://www.rackaid.com/resources/tips/rsync-ssh.cfm
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #12 on: May 25, 2005, 12:07:19 AM »
The rason why i could not find out about using rsync the last time was because I could not find out about using the rsync server.

What is "the rsync program" is a client or is it a server, or is it both ? How do you eventually start the rsync deamon ?

If you combine the use of a rsync client with some other deamon, lets say a ssh deamon, could you then logon using a "rsync client" from the backupstation to the ssh deamon at the server that should be backed up, using the rsync to "pull out the file copies" from the server that should be backed up to the "backupserver" ?

For me this sounds a little bit reasonable because when you use the winscp program on Windows and against a ssh deamon you are doing some manual file management that is a little bit equal ??!!

The man page for rsync:
http://samba.anu.edu.au/ftp/rsync/rsync.html

Is is anyboudy of you who know if there really exist something like a rsync deamon, and if that is the same or something different than the rsync vlient program. I would gues that "using the ssh deamon method" could work, but it would be interesing to know and understand "the full story" ..

Arne.
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #13 on: May 25, 2005, 12:28:16 AM »
well this gives me at last a prompt for a password .. have never come as long as that before ..

 rsync --archive --rsh=/usr/bin/ssh --verbose root@domene1.com:./arne ./arne

Arne
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #14 on: May 25, 2005, 12:44:07 AM »
This actually worked, syncronising the folder /arne from a remoote sme 6.0.1 over to a loval Linux Centos server.

I think the way it works is by using the ssh deamon on the sme server for logon, transport via ssh and then the rsync client on the local Centos server (that could had been a sme server as well, but it is a Centos test server just now.)

 rsync --archive --rsh=/usr/bin/ssh --verbose root@domene1.com:/arne /arne

OK, I think that this can work and the rest of the problem is to find out wich files to syncronize and how to dump and restore database files etc.

I think the last time I did this (with a usb harddisk) I hacked into the sme bacup routines. Dont remember where, but I think it was somewhere a clear text file where you could read out all info about the standard sme backup.

I have just tested it a little bit, but just now and initially it looks like it should be possible to syncronize any servers anywhere via Internet.

Arne.
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #15 on: May 25, 2005, 01:05:07 AM »
A small adjustment ..

This will recorsively copy all the content of the whole directory /arne from the remote PC to the directory /arne at the local PC.

rsync --archive --rsh=/usr/bin/ssh --verbose root@domene.com:/arne /

Looks like one ibay can be done using only one command.

Ok, I think there should be a script first dumping the approciate databases and the transfering files with rsync.

Arne
......

Offline Brenno

  • *****
  • 208
  • +0/-0
How to syncronise 2 sme servers
« Reply #16 on: May 25, 2005, 02:52:23 AM »
arne,

Sounds like you're making progress there!  I just discovered why sync2nas won't work - it doesn't support SSH and therefore SME blocks the connections at the firewall level (rsync uses port 873.)  Not sure why I was under the impression that sync2nas would work :(

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #17 on: May 25, 2005, 04:21:07 PM »
The question: "how to open one port in the firewall" were up here int he forum for some days ago.

I answered it out and "someone" tested it out and confirmed that it worked. (I could't myself becaus I did not have the right equipement just now. You could try to search for it ..
......

Offline gelcube

  • ***
  • 55
  • +0/-0
    • http://www.ninetails.net
How to syncronise 2 sme servers
« Reply #18 on: May 25, 2005, 04:44:06 PM »
Quote from: "arne"
Then I started to develop a solution based on the use of the principle of making bacup using a number of cheap USB harddisks for full data backups.

The tasks were automated in such a way that you just had to plug in the usb harddisk for instance in the evening and pick up the full backup in the morning.

This solution were improved until I could not imagine how to improve it more, and then the whole project were packed down, because I really do not use such a backup capacity for my homeserver. The whole project were made mostly for "fun" and the exitement to see if it could work.

I don't know if usb harrdiks is considered to be a "safe enough" medium for backup, but it seems to work rather good. By the way for making it I hacked into the backupfunctions of the sme server to make bacups of the identical same files including dumps from the databases.

What about starting up such a project "backup to the usb harddisk" and then this time with someone with the knowledge of making a server-manager front end ?! (in my project it was just a collection of shell scripts.)



Is there anyway you could post these scripts and a how-to?  I'd be very interested in it...even without a server manager frontend.

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #19 on: May 26, 2005, 01:37:25 AM »
The question would rather be how and where to find it again. It was developed trough a discussion here at the contibs.org for a year or two ago, so it should be here as well, if one search for it.

Anyhow it should not be a to big task to redevelop it.

Actually a "backup to usb harddisk" and "syncronice two sme servers" could be two wery close projects, actually so close that both cluld be developed in one new project.

The difference could be that the one method mounts a usb harddisk while the other etsablish a rsync/ssh connection.

Most of the stuff using rsync to copy/syncronizing files, database bacup, restore etc would be common.

By the way used rsync for the usb hd as well as I were not able to find out how to use the rsync over the net at that time.

I have two servers at the moment, one sme 6.0.1 in my friends house (he got a lot bether internet line than me) and a centos server in my home.

I am thinking a little bit now if I should try to set up a sme server in my home as well and then try to make some automatic routines to syncronize these two servers.

If "somebody else" took the "check out of the usb part" of the project, I could eventuelly think about doing the "syncronize the servers project".

Actually 95 % of those two "project halves" could be identical with only minor "adjusments" for passing the datas to the usb harddisk or to the other server.

"Passing the datas to the other server" was that part of it I had to give up the last time, so it cluld be something .. :-)

By the way another discussion about storing the datas to the usb harddisk is "should the datas be stored just as individual files reflecting an existing datastructure or should they be for instanse collected to one compressed file.

There is one thing about this rsync function, at least as it worked for me. It is not "bidirectional" in that way, it syncronize the one way, but not the other. That will say it will not delete all old garbage files on the usb backup if they are deleted on the server. All reviced files at the server will be copied over to the usb disc via rsync, but old files that are deleted on the server will not be deleted on the "rsync image". So if you have to do a restore you will restore all the newest files pluss all the old garbage that should be deleted.

Don't know what's the best way to handle this "delete the old files on the backup" problem.

Arne
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #20 on: May 26, 2005, 01:44:43 AM »
By the way the "get rid of the garbage problem" could be just a question of using the right parameters for the rsync .. dont know, but I can se that the "man rsync" has a lot of info.

Arne.
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #21 on: May 26, 2005, 01:59:55 AM »
Think I found something about the "garbage problem" here:

To delete files that are on the destination system but no longer on the source system, use the --delete option:

e.g.:

rsync -e ssh -avz --delete /lib/ root@myserver.com:/lib/

http://wiki.linuxquestions.org/wiki/Rsync
......

blockbuster

How to syncronise 2 sme servers
« Reply #22 on: May 29, 2005, 05:55:29 PM »
Arne you wrote:

This will recorsively copy all the content of the whole directory /arne from the remote PC to the directory /arne at the local PC.

rsync --archive --rsh=/usr/bin/ssh --verbose root@domene.com:/arne /

If you do this from a windows machine via putty you will copy all documents of /arne into the / directory on both the remote machine.

I don't see any code to get it to the local machine but would be happy to have it. I mean you need something to define as an ip adres to backup to?! or two ip's one to the internet router, and 1 to the internal network?!

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #23 on: May 29, 2005, 11:06:35 PM »
I think this one apeared to be the best variant (event though I havent tested it out to much yet - both works but  i believe that the last one work "best" as it also delete old files that should be deleted).

rsync -e ssh -avz --delete /lib/ root@myserver.com:/lib/

the pronsipple is very easy. the souce is allways to the left and destignation to the right in the adress. Ip is resolved to myserver.com automatic.

From local to remote:

rsync -e ssh -avz --delete /lib/ root@myserver.com:/lib/

From remote to local:
rsync -e ssh -avz --delete root@myserver.com:/lib/ /lib/

Syncronising the directory /lib/ recursively.

It might sount rather stupid, but I had never thought about the rsync as something that can be used at a Windows work station. I have only used it between Linux machines.

You will need a rsync and a ssh client ? How to install ?

Arne.
......

cydonia

How to syncronise 2 sme servers
« Reply #24 on: May 30, 2005, 02:45:29 AM »
Quote from: "arne"

It might sount rather stupid, but I had never thought about the rsync as something that can be used at a Windows work station. I have only used it between Linux machines.

You will need a rsync and a ssh client ? How to install ?

Arne.



Isn't it possible to rsync to a Samba share?

blockbuster

How to syncronise 2 sme servers
« Reply #25 on: May 30, 2005, 03:46:03 PM »
Installation (Windows 95/98/NT4/2k/XP)
To use rsync, you first have to have ssh running. Don't even think about using rsh, and you probably don't want to rely on the built-in rsync transport.

   1. Unpack rsync_full e.g. as c:\rsync.

   2. Edit the rsetup.bat file. This is a simple batch file that defines your username and home directory and path; modify the appropriate two lines.

   3. Open a DOS or NT command window and go to the appropriate directoy, e.g. cd \rsync

   4. Set the path etc. by running rsetup.


For complete how to goto:
http://optics.ph.unimelb.edu.au/help/rsync/rsync_pc1.html


According to the ssh client:

Wouldn't Putty, WinSCP3 or Terre Term Pro do the job?

blockbuster

How to syncronise 2 sme servers
« Reply #26 on: May 30, 2005, 04:16:10 PM »
Quote
Isn't it possible to rsync to a Samba share?


I think it's possible but the nice thing from ssh is that you can do it over an insecure network like the internet. The good thing about Rsync is that you do incremental backup so you don't have to push to many mb's over the internet which is taking to much time and too much bandwith.  

In my situation I live part time in Europe and part time in South  America, I am keen on doing backups over the two continents. Since my adsl in South America isn't that strong I am looking in this direction to backup.

Other way to follow via openVPN and SambaShares, but I don't like to depent on that too much since I haven't configured it that stable at the moment.

Offline Brenno

  • *****
  • 208
  • +0/-0
How to syncronise 2 sme servers
« Reply #27 on: May 30, 2005, 08:56:00 PM »
I've almost got this working... almost.  I setup OpenSSH on XP Pro, then simply wrote a .bat file which contains the following:

Code: [Select]
@ECHO OFF
ECHO **********************************************************
ECHO rsync.bat - Batch file to start your rsync command (s).
ECHO **********************************************************

SET CWRSYNCHOME="c:\progra~1\OpenSSH\bin"

REM ** CUSTOMIZE ** Enter your rsync command(s) here

SET RSYNCCMD=rsync -e %CWRSYNCHOME%\ssh -av --delete
SET REMOTE=user@domain.com::user

c:
cd \
SET DIRS=testing
echo Backing up from C: drive: %DIRS%
%RSYNCCMD% %DIRS% %REMOTE%/c

set CWRSYNCHOME=

pause


(The "pause" at the end is just a thingy to keep the window from closing immediately.)

The idea is that you can then use Windows Scheduler to execute the .bat file whenever you want.

Trouble is, I get a password prompt for user, but once I enter the password, I get the following errors:

Code: [Select]
TERM environment variable not set.
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/tmp/rysnc-2.6.3/io.c(515)


This is where I get stuck.  No matter what I do, I can't get this to complete the transaction.  Anyone have any ideas?

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #28 on: May 31, 2005, 03:33:11 AM »
I did not even know it was a OpenSh server for windows, but I can now see that there is.

If you install the Windows OpenSSH server will you then also got a client ?

I found some info here:
http://freessh.org/windows.html

Best reg Arne.
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #29 on: May 31, 2005, 03:40:24 AM »
Brenno ->

No, it was not a openssh client (??) on that link (or is it ??)

Is there some place to download a openssh client ? (Or how do you set up the ssh trafic from windows ?)

Arne.
......

Offline Brenno

  • *****
  • 208
  • +0/-0
How to syncronise 2 sme servers
« Reply #30 on: May 31, 2005, 10:46:01 PM »
arne,

I actually went through http://sshwindows.sourceforge.net. From there, I clicked on the Downloads link near the bottom and then on the Binary Installer Releases link.

Of course, you could always install Cygwin, which contains OpenSSH components as well as an rsync implementation for Windows.

Installing it is the easy part - getting it work across a WAN is the hard part.  Let me know if you have any successes!

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #31 on: June 04, 2005, 06:44:47 PM »
I found one tread from "the old days"

It contains a script for dumping all the databases.

http://forums.contribs.org/index.php?topic=19331.msg76548#msg76548

Somewhere in the sme 5.6 I found a perl script that specefied all the directories that should be backed up.

I am not able to find it again on the sme 6.0.1

Anybody who knows ?

Arne.
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #32 on: June 04, 2005, 06:49:19 PM »
Possibly another way of dumping the databases ?
http://dev.mysql.com/doc/mysql/en/mysqldump.html
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #33 on: June 04, 2005, 06:54:57 PM »
I think this were the directories I copied the last time (But have no documentation and can not find the right perl backuscript wich specifies the directories).

rsync -auq /home/e-smith/ /mnt/backup/blackie/home/e-smith/
rsync -auq /home/netlogon/ /mnt/backup/blackie/home/netlogon/
rsync -auq /etc/e-smith/templates-custom/ /mnt/backup/blackie/etc/e-smith/templates-custom/
rsync -auq /etc/e-smith/templates-user-custom/ /mnt/backup/blackie/etc/e-smith/templates-user-custom/
rsync -auq /etc/group /mnt/backup/blackie/etc/group
rsync -auq /etc/gshadow /mnt/backup/blackie/etc/gshadow
rsync -auq /etc/passwd /mnt/backup/blackie/etc/passwd
rsync -auq /etc/shadow /mnt/backup/blackie/etc/shadow
rsync -auq /etc/smbpasswd /mnt/backup/blackie/etc/smbpasswd
rsync -auq /etc/ssh/ /mnt/backup/blackie/etc/ssh/
rsync -auq /opt/ /mnt/backup/blackie/opt/
rsync -auq /root/ /mnt/backup/blackie/root/

"blackie" is the name of the server.
......

Offline arne

  • *****
  • 1,116
  • +0/-4
How to syncronise 2 sme servers
« Reply #34 on: June 04, 2005, 06:59:17 PM »
And this should be the command for rsync via ssh and network:

From local to remote:

rsync -e ssh -avz --delete /lib/ root@myserver.com:/lib/

From remote to local:
rsync -e ssh -avz --delete root@myserver.com:/lib/ /lib/

The databases have to be dumped and resored and the actual directories have to be "rsynced".

Anybody who knows the perl script that specifies the actual directories ?
......

mbachmann

How to syncronise 2 sme servers
« Reply #35 on: June 06, 2005, 11:13:10 AM »
I recommend backuppc to you. It is not mirroring the machine (as i understand you want mirroring to a 2nd machine). But once you have it up and running you can most easily restore data. Plus: you can keep more than 1 one full backup.

http://forums.contribs.org/index.php?topic=24320.0