LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-14-2008, 11:13 AM   #1
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Rep: Reputation: 0
Question How to copy entire contents


I have 2 servers. One is at the main location and the other is off-site. I need to do a scheduled job to copy the entire contents of the server at the main location to the server at the off-site location. I thought I had it, but it isn't working properly, so I need to start from scratch. I keep getting "permissions denied" or "file doesn't exist" messages. If I get the permissions denied, then I have to go to the main server and chmod the file. If I get a file or destination doesn't exist, it's because the remote server doesn't have that subdirectory yet.

Also, the main server is Red Hat 9 and the remote servers are either Red Hat 9 or Centos...if that helps...

What can I do? PLEASE HELP!!
 
Old 02-14-2008, 11:16 AM   #2
Cichlid
Member
 
Registered: Jan 2002
Location: Montreal
Distribution: Ubuntu 8.10
Posts: 178

Rep: Reputation: 30
Years ago I was in a similar situation. A local guru was working with cpio. Man this on your system. It may be of help.

Good luck
 
Old 02-14-2008, 11:31 AM   #3
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Original Poster
Rep: Reputation: 0
I'm just trying to basically backup a server's directory to another server by scheduling a copy. Does the cpio look for archive files? I just need to copy any files that have been modified since the last copy, etc... Does this make sense?
 
Old 02-14-2008, 12:10 PM   #4
aot2002
Member
 
Registered: Dec 2003
Location: NY
Distribution: Ubuntu 7.10
Posts: 66

Rep: Reputation: 15
Quote:
Originally Posted by brick_46143 View Post
I'm just trying to basically backup a server's directory to another server by scheduling a copy. Does the cpio look for archive files? I just need to copy any files that have been modified since the last copy, etc... Does this make sense?
why dont you just create a cron job to run a bash script that uses rsync to copy the incremental changes as needed if permissions are a different user on the other system you can do this too in rysnc.
learn rsync using man rsync

I hope your not using redhat 9 its extremely old and full of bugs and exploit's please use something more up to date.
look at fedora or redhat enterprise its cheap

Last edited by aot2002; 02-14-2008 at 12:11 PM.
 
Old 02-14-2008, 12:44 PM   #5
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Original Poster
Rep: Reputation: 0
So if I am looking at this correctly it would say as follows:

rsync /test/dsk01 joe@remoteserver:/test/dsk01

What are the "OPTION"? Are these switches like you'd use in DOS (ie: xcopy test\*.* e:\test1\*.* /d /e /f) telling the program just to do files that are newer, subdirectories, etc...?

How do I create a cron job to run a bash script and how do I create a bash script?

I know it's alot to probably ask, but I'm new at this and need some help.

BTW-The servers currently are RH9, but we are converting to a newer OS. I just takes time.
 
Old 02-14-2008, 02:10 PM   #6
aot2002
Member
 
Registered: Dec 2003
Location: NY
Distribution: Ubuntu 7.10
Posts: 66

Rep: Reputation: 15
Quote:
Originally Posted by brick_46143 View Post
So if I am looking at this correctly it would say as follows:

rsync /test/dsk01 joe@remoteserver:/test/dsk01

What are the "OPTION"? Are these switches like you'd use in DOS (ie: xcopy test\*.* e:\test1\*.* /d /e /f) telling the program just to do files that are newer, subdirectories, etc...?

How do I create a cron job to run a bash script and how do I create a bash script?

I know it's alot to probably ask, but I'm new at this and need some help.

BTW-The servers currently are RH9, but we are converting to a newer OS. I just takes time.
I would make sure those rh9 servers are not on the internet at all or accessible if they are they are extremely dangerous.


rsync has many options you need to find which ones fit your needs.
use man rsync to learn more

http://www.mikerubel.org/computers/rsync_snapshots/
 
Old 02-15-2008, 12:05 AM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
If you are that new to Linux, you'll find this invaluable: http://rute.2038bug.com/index.html.gz

but in short
1. to create a cron job:
login as root
crontab -e (will open root's crontab)
add job with the timing params (see here http://www.adminschoice.com/docs/cro...Crontab%20file ) ie location of your rsync cmd (shell) file eg /root/my_rsync.sh

2. create a shell file (aka cmd file)
you'll need to learn an editor eg kate, gedit, vim etc

btw, the default editor for the crontab will probably be vi/vim, so learn the basics of that anyway, it's the default Unix editor.

Keep posting qns here...

Other good links: http://www.tldp.org/LDP/abs/html/
http://wiki.linuxquestions.org/wiki/...ndows_software
http://linux.oneandoneis2.org/LNW.htm

Last edited by chrism01; 02-20-2008 at 06:17 PM.
 
Old 02-20-2008, 08:15 AM   #8
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Original Poster
Rep: Reputation: 0
So do I use vi to create a file like mybak.bas and then do I need to compile it into a mybak.cmd? If so, how do I do that?
 
Old 02-20-2008, 11:41 AM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
No, you don't compile them. A shell script is similar to a
.bat or .cmd in windows. They get executed by the shell
(command processor in windows).


Cheers,
Tink
 
Old 02-22-2008, 10:42 AM   #10
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Original Poster
Rep: Reputation: 0
I am understanding rsync now, but I'm getting the following error when try to connect to a remote server.

I do the following:

rsync -av /vm/miame/dsk01/ user@192.168.0.189:vm/miame/dsk01

And this happens:

backupsvr.localhost.localdomain: Connection refused
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(150)


PLEASE...SOMEONE HELP!! I'm sure I'm really close, but i need hlpe as to why it's not even asking me for a password. I can ssh into the remote server from the local server also with no problem.
 
Old 02-23-2008, 11:59 AM   #11
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Question

OK. I think I found that I need to install the remote server as a rsync server. I create a rsync.conf file in /etc. Then when I try to run /etc/init.d/rsyncd start it says file not found. Do I need to install this module? How do I do this on RedHat9 and CentOS?
 
Old 02-25-2008, 06:43 AM   #12
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Ok. I've gotten it to start, but now I get a broken pipe error. What is that?
 
Old 02-25-2008, 07:44 AM   #13
lord-fu
Member
 
Registered: Apr 2005
Location: Ohio
Distribution: Slackware && freeBSD
Posts: 676

Rep: Reputation: 30
Hi.

Why don't you run the script on the server that needs to be updated, that way you are not pushing changes. Instead have the 2nd machine pull changes and deletions from the 1st server.

Here is an example for a backing up an asterisk voicemail directory.

Code:
rsync -avz --delete --timeout=999 --exclude-from=/user/.rsync/exclude -e ssh  user@192.168.X.X:/var/spool/asterisk/voicemail /var/spool/asterisk/
Note the above needs to be on one line, very well could be your broken pipe error message.

I use ssh-keypairs to allow secure unattended backups without using a plain text password stored in the script, in this example is also the use of the .exclude file to allow certain items to be excluded during the backup.

hth

Last edited by lord-fu; 02-25-2008 at 08:02 AM.
 
Old 02-25-2008, 07:59 PM   #14
brick_46143
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Original Poster
Rep: Reputation: 0
That works. I am having a small problem. I think the last one. There is server1 and server2. On both servers there is a /vm/miame/dsk01. When I pull the info with the following:

rsync -av --timeout=999 -e ssh user01@192.168.0.199:/vm/miame/dsk01 /vm/miame/dsk01

This creates a dsk01 directory in /vm/miame/dsk01 on server2. So instead of having the contents on server2 to be in /vm/miame/dsk01, it's in /vm/miame/dsk01/dsk01. I can't seem to see what I'm doing wrong...again.

Please help. Thanks to all for their help.
 
Old 02-26-2008, 08:21 AM   #15
lord-fu
Member
 
Registered: Apr 2005
Location: Ohio
Distribution: Slackware && freeBSD
Posts: 676

Rep: Reputation: 30
That would be

Code:
rsync -av --timeout=999 -e ssh user01@192.168.0.199:/vm/miame/dsk01   /vm/miame/
hth
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
chown, chgrp an entire directoy and contents gin1 Red Hat 8 09-06-2013 02:48 AM
Copy an entire document in Vi to clipboard geokker Linux - Newbie 2 08-06-2009 03:14 PM
comparing the contents of entire CDs newbiesforever General 3 08-26-2007 07:03 PM
how to delete entire contents of file using vi editor once sunlinux Linux - General 1 08-17-2007 05:48 AM
Copy an entire install to second harddisk seriesx4 Linux - General 7 10-13-2005 11:44 AM


All times are GMT -5. The time now is 04:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration