Rsync

This is a discussion on Rsync within the Linux Networking forums, part of the Linux Forums category; Hi, I have 2 servers. One is a web/mail server and the other is a backup server. Currently, to ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-23-2008
Mtek
 
Posts: n/a
Default Rsync


Hi,

I have 2 servers. One is a web/mail server and the other is a backup
server. Currently, to back up the server I have a script that runs
which basically tar's the entire apache tree along with dumps of the
MySQL databases and use SCP to send them to the backup server.

Later, a script runs on the backup server which untar's the files and
imports the databases.

My question is, is this a good backup method? I see many people using
RSYNC. Would this be a better solution? If yes, how would I do it??

Thank you for your help and advice.

John
Reply With Quote
  #2 (permalink)  
Old 07-23-2008
Unruh
 
Posts: n/a
Default Re: Rsync

Mtek <mtek@mtekusa.com> writes:


>Hi,


>I have 2 servers. One is a web/mail server and the other is a backup
>server. Currently, to back up the server I have a script that runs
>which basically tar's the entire apache tree along with dumps of the
>MySQL databases and use SCP to send them to the backup server.


>Later, a script runs on the backup server which untar's the files and
>imports the databases.


>My question is, is this a good backup method? I see many people using

OK but cumbersome.
>RSYNC. Would this be a better solution? If yes, how would I do it??


Yes, it would be. rsync also checks the data for correctness ( hashes the
same) while transfering it.

It also transfers only what has changed, not everything every time.


The "easy" way

rsync -av /usr/local/http/ remotehost:/usr/local/http
rsync -av /usr/local/mysql/ remotehost:/usr/local/mysql


which will use sshd so you would need a passwordless login on the remote
machine.
(Assuming of couse that the apache tree is in /usr/local/http and that the
sql databases are in /usr/local/mysql on both machines. Change to conform
to what you actually have.)

Note that that last / on the first path is necessary. No slash means copy
the directory name as well as its contents, while a terminal / means
transfer just the contents.
-a means preserve the times, the owners and the permissions.

(v is for verbose. If you want it to be quiet, use q instead)

Lots more possiblities. -- excluding some directories or files, etc.
man rsync.

If you want it slightly faster, put an rsync daemon on the remote machine

exit /etc/rsync.conf on the remotehost and put in something like
[apache]
path=/usr/local/http
uid=0
gid=0
hosts allow=yourhost.yourdomain.com
hosts deny=0.0.0.0/0
readonly=false
timeout=600
[sql]
path=/usr/local/sql
uid=0
gid=0
hosts allow=yourhost.yourdomain.com
hosts deny=0.0.0.0/0
readonly=false
timeout=600

Then call it with
rsync -av /usr/local/http/ remotehost::apache
rsync -av /usr/local/sql/ remotehost::sql


Make sure that the
disable=no
is in /etc/xinetd.d/rsync
on the remotehost



>Thank you for your help and advice.


>John

Reply With Quote
  #3 (permalink)  
Old 07-23-2008
Mtek
 
Posts: n/a
Default Re: Rsync

On Jul 22, 9:30*pm, Unruh <unruh-s...@physics.ubc.ca> wrote:
> Mtek <m...@mtekusa.com> writes:
> >Hi,
> >I have 2 servers. *One is a web/mail server and the other is a backup
> >server. *Currently, to back up the server I have a script that runs
> >which basically tar's the entire apache tree along with dumps of the
> >MySQL databases and use SCP to send them to the backup server.
> >Later, a script runs on the backup server which untar's the files and
> >imports the databases.
> >My question is, is this a good backup method? *I see many people using

> OK but cumbersome.
> >RSYNC. *Would this be a better solution? *If yes, how would I do it??

>
> Yes, it would be. rsync also checks the data for correctness ( hashes the
> same) while transfering it.
>
> It also transfers only what has changed, not everything every time.
>
> The "easy" way
>
> rsync -av /usr/local/http/ remotehost:/usr/local/http
> rsync -av /usr/local/mysql/ remotehost:/usr/local/mysql
>
> which will use sshd so you would need a passwordless login on the remote
> machine.
> (Assuming of couse that the apache tree is in /usr/local/http and that the
> sql databases are in /usr/local/mysql on both machines. Change to conform
> to what you actually have.)
>
> Note that that last / on the first path is necessary. No slash means copy
> the directory name as well as its contents, while a terminal / means
> transfer just the contents.
> -a means preserve the times, the owners and the permissions.
>
> (v is for verbose. If you want it to be quiet, use q instead)
>
> Lots more possiblities. -- excluding some directories or files, etc.
> man rsync.
>
> If you want it slightly faster, put an rsync daemon on the remote machine
>
> exit /etc/rsync.conf on the remotehost and put in something like
> [apache]
> path=/usr/local/http
> uid=0
> gid=0
> hosts allow=yourhost.yourdomain.com
> hosts deny=0.0.0.0/0
> readonly=false
> timeout=600
> [sql]
> path=/usr/local/sql
> uid=0
> gid=0
> hosts allow=yourhost.yourdomain.com
> hosts deny=0.0.0.0/0
> readonly=false
> timeout=600
>
> Then call it with
> rsync -av /usr/local/http/ remotehost::apache
> rsync -av /usr/local/sql/ remotehost::sql
>
> Make sure that the
> disable=no
> is in /etc/xinetd.d/rsync
> on the remotehost
>
>
>
> >Thank you for your help and advice.
> >John- Hide quoted text -

>
> - Show quoted text -


Thanks Unrhu. I have 2 quick questions:

>Note that that last / on the first path is necessary. No slash means copy
>the directory name as well as its contents, while a terminal / means
>transfer just the contents.


What is the difference? Why not copy the name as well?


>If you want it slightly faster, put an rsync daemon on the remote machine


What will speed up? How is that config faster?

Thanks again! It is a lot of help.

John




Reply With Quote
  #4 (permalink)  
Old 07-23-2008
H.Janssen
 
Posts: n/a
Default Re: Rsync

Hello Mtek,






Mtek wrote:

>> >RSYNC. *Would this be a better solution? *If yes, how would I do it??

>>


Apart from the goodies described before, rsync has another nice option:
you can make several copies of your data with minimal loss of diskspace:
rsync is able to make copies with hardlinks if the data are identical.
(--link-dest=DIR)
In that case, the new version is a hardlink to the old version, so you have
two directory entries pointing to the same data. If the file is changed,
original and new file are stored separately. Of course, your database will
continuously change, if this is the major part, it does not make that much
difference.
Anyhow, if things get messed up, you have two or more generations...
You can implement schemes like, in shorthand notation:

rsync --link-dest=1 ..... 0
if success ( important!!!)
rm -rf 3
mv 2 3
mv 1 2
mv 0 1


In addition, rsync is an excellent program to transfer data via slow links,
e.g. to a remote system for backup, because only changed data are
transferred. Adding a small message to a big plain text email file means
only transfer of block checksums and the last "blocksize" bytes....

Kind Regards,
H,Janssen

Reply With Quote
  #5 (permalink)  
Old 07-23-2008
Unruh
 
Posts: n/a
Default Re: Rsync

Mtek <mtek@mtekusa.com> writes:


>Thanks Unrhu. I have 2 quick questions:


>>Note that that last / on the first path is necessary. No slash means copy
>>the directory name as well as its contents, while a terminal / means
>>transfer just the contents.


>What is the difference? Why not copy the name as well?


say the directory dir has a file /dir/file in it.

rsync -av /dir remote:/far
will have in /far the subdirectory called dir which contains the file
"file"
Ie /far/dir/far
rsync -av /dir/ remote:/far

has the contents of /dir in /far
Ie
/far/file





>>If you want it slightly faster, put an rsync daemon on the remote machine


>What will speed up? How is that config faster?


No ssh encryption.

So if it is sensitive data, use the first. If it is not, use the second.
slightly faster. Also control is by the host allow in /etc/rsync.conf,
rather than via ssh password or ssh key.






Reply With Quote
  #6 (permalink)  
Old 07-23-2008
Frank Elsner
 
Posts: n/a
Default Re: Rsync

Unruh wrote:
> Mtek <mtek@mtekusa.com> writes:
>
>
>
>>Hi,

>
>
>>I have 2 servers. One is a web/mail server and the other is a backup
>>server. Currently, to back up the server I have a script that runs
>>which basically tar's the entire apache tree along with dumps of the
>>MySQL databases and use SCP to send them to the backup server.

>
>
>>Later, a script runs on the backup server which untar's the files and
>>imports the databases.

>
>
>>My question is, is this a good backup method? I see many people using

>
> OK but cumbersome.
>
>>RSYNC. Would this be a better solution? If yes, how would I do it??

>
>
> Yes, it would be. rsync also checks the data for correctness ( hashes the
> same) while transfering it.
>
> It also transfers only what has changed, not everything every time.


What about database file with holes, postgres comes to my mind.
Is it save to rsync them?


--Frank
Reply With Quote
  #7 (permalink)  
Old 07-23-2008
Mtek
 
Posts: n/a
Default Re: Rsync

On Jul 23, 6:54*am, Frank Elsner <Frank.Els...@spamfence.net> wrote:
> Unruh wrote:
> > Mtek <m...@mtekusa.com> writes:

>
> >>Hi,

>
> >>I have 2 servers. *One is a web/mail server and the other is a backup
> >>server. *Currently, to back up the server I have a script that runs
> >>which basically tar's the entire apache tree along with dumps of the
> >>MySQL databases and use SCP to send them to the backup server.

>
> >>Later, a script runs on the backup server which untar's the files and
> >>imports the databases.

>
> >>My question is, is this a good backup method? *I see many people using

>
> > OK but cumbersome.

>
> >>RSYNC. *Would this be a better solution? *If yes, how would I do it??

>
> > Yes, it would be. rsync also checks the data for correctness ( hashes the
> > same) while transfering it.

>
> > It also transfers only what has changed, not everything every time.

>
> What about database file with holes, postgres comes to my mind.
> Is it save to rsync them?
>
> --Frank- Hide quoted text -
>
> - Show quoted text -


Well, are you also saying that I do not need to export and re-import
the database tables? That it will copy the databse files and mySQL
will work fine on the backup server?

My goal obviously is if the main server goes down, I can shut it down,
change my router to point to the other server, and I'm up and running
again.

Regards,

John.
Reply With Quote
  #8 (permalink)  
Old 07-23-2008
Alessandro Topo Galileo
 
Posts: n/a
Default Re: Rsync

Il 23/07/2008 15.06, Mtek ha scritto:

> My goal obviously is if the main server goes down, I can shut it down,
> change my router to point to the other server, and I'm up and running
> again.


For mysql I think it is better to recreate database from mysqldump files.
Doing this, you will loose changes made after mysqldump command.
If this is not acceptable, you can set up mysql in master/slave mode and
your slave has always the same data that master has. See mysql
documentation on how to set up this, it is quite simple.
Reply With Quote
  #9 (permalink)  
Old 07-23-2008
Mtek
 
Posts: n/a
Default Re: Rsync

On Jul 23, 8:21*am, Alessandro Topo Galileo
<toglituttofinoalpunto.ale...@email.it> wrote:
> Il 23/07/2008 15.06, Mtek ha scritto:
>
> > My goal obviously is if the main server goes down, I can shut it down,
> > change my router to point to the other server, and I'm up and running
> > again.

>
> For mysql I think it is better to recreate database from mysqldump files.
> Doing this, you will loose changes made after mysqldump command.
> If this is not acceptable, you can set up mysql in master/slave mode and
> your slave has always the same data that master has. See mysql
> documentation on how to set up this, it is quite simple.



And going along with that, you still think RSYNC is a better idea than
ratting up specific directories and untarring them on the backup
server?

Reply With Quote
  #10 (permalink)  
Old 07-23-2008
Unruh
 
Posts: n/a
Default Re: Rsync

"H.Janssen" <henny@nospam.hmmsjan.dosgg.nlnospam> writes:

>Hello Mtek,


>





>Mtek wrote:


>>> >RSYNC. *Would this be a better solution? *If yes, how would I do it??
>>>


>Apart from the goodies described before, rsync has another nice option:
>you can make several copies of your data with minimal loss of diskspace:
>rsync is able to make copies with hardlinks if the data are identical.
>(--link-dest=DIR)
>In that case, the new version is a hardlink to the old version, so you have
>two directory entries pointing to the same data. If the file is changed,
>original and new file are stored separately. Of course, your database will
>continuously change, if this is the major part, it does not make that much
>difference.
>Anyhow, if things get messed up, you have two or more generations...


Depends on what things get messed up. If the backup gets messed up then all
versions get messed up since they are all the same thing. That could be a problem
However, the ability to have detailed backups from many different dates can
be a huge advantage if the backup itself is not comprimised.


>You can implement schemes like, in shorthand notation:


>rsync --link-dest=1 ..... 0
>if success ( important!!!)
> rm -rf 3
> mv 2 3
> mv 1 2
> mv 0 1



>In addition, rsync is an excellent program to transfer data via slow links,
>e.g. to a remote system for backup, because only changed data are
>transferred. Adding a small message to a big plain text email file means
>only transfer of block checksums and the last "blocksize" bytes....


Yup. Great feature.

>Kind Regards,
>H,Janssen


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:46 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0