LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-22-2009, 05:55 AM   #1
nishith
Member
 
Registered: Aug 2008
Posts: 148

Rep: Reputation: 15
Merge 2 same name directories in linux.


Hello,

I have created two same directories on two different locations. The structure is as shown below.

/web_upload/
/mnt/web_upload/

Now, I want to merge all contents of both "web_upload" directories into one directory. Simply,i want to copy all data & files from "/web_upload" to "/mnt/web_upload/" , without affecting original data on "/mnt/web_upload/"

Please Help.


Nishith Vyas
 
Old 09-22-2009, 07:05 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
yes n | cp -ir web_upload/* /mnt/web_upload

Read man pages of "yes" and "cp"
 
Old 09-23-2009, 02:00 AM   #3
nishith
Member
 
Registered: Aug 2008
Posts: 148

Original Poster
Rep: Reputation: 15
Question Merge without affecting existing directories & files,having same name.

Dear Friend,

Thanks for prompt reply. As per the "cp" command, I want to ask you simple question.

Will "cp" command overwrite same named directories? Suppose,i have 2 same named directories in 2 different folders. The scenario is given below.

"/data/web_upload/data_27/" directory contains,
file1
file2
file3
SQL Directory

"/mnt/web_upload/data_27/" directory contains,
file1
file2
file4
SQL Directory

So, it is clear that file1,file2 & SQL Directory - common on both directories.

Now, please let me know how to merge all data without overwriting existing files & directories?

Please Help.
 
Old 09-23-2009, 02:54 AM   #4
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
It is hard to make cp overwrite entire directories - it will just copy corresponding files into it. Of course there can be name conflicts between files. That's why I recommend studying "-i" option (interactive, implies asking on overwrite) and piping "yes n" (infinite stream of "n") to cp (that way you decline all overwrite requests.
 
Old 09-23-2009, 04:08 AM   #5
nishith
Member
 
Registered: Aug 2008
Posts: 148

Original Poster
Rep: Reputation: 15
rsync over ssh

If the remote server don't have "rsync",on which i want to copy data from linux pc,Will "rsync" work?

Simply, i want to merge all data & files on UNIX PC,which don't have"rsync" package. I want to copy all data from linux pc,having "rsync" utility.

is it possible?

What "rsync over ssh" will do?
 
Old 09-23-2009, 04:10 AM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
No, rsync over ssh assumes existence of rsync on both sides.
 
Old 09-23-2009, 07:55 AM   #7
nishith
Member
 
Registered: Aug 2008
Posts: 148

Original Poster
Rep: Reputation: 15
Question rsync configuration.

I want to configure "rsync" on centos 5.2 pc.

after the configuration, "rsync" doesn't show me the "/etc/rsync.conf" file,which is necessary for configuration.

Kindly provide me a good documentation for "rsync"



Thanks in advance.
 
Old 09-23-2009, 08:41 AM   #8
rn_
Member
 
Registered: Jun 2009
Location: Orlando, FL, USA
Distribution: Suse, Redhat
Posts: 127
Blog Entries: 1

Rep: Reputation: 25
Quote:
Originally Posted by nishith View Post
doesn't show me the "/etc/rsync.conf" file
do you mean /etc/rsyncd.conf ? I am not aware of any requirement for a plain rsync.conf since most of the options are provided on the command-line or from the ssh config files.

unless you want to run this as a daemon process, you don't need rsyncd.conf.

as for documentation, all i can suggest is man and google , or if you need help with something specific, maybe someone here can help.

HTH.
-RN.
 
Old 09-24-2009, 01:56 AM   #9
nishith
Member
 
Registered: Aug 2008
Posts: 148

Original Poster
Rep: Reputation: 15
Exclamation rsync scenario.

Dear Friend,

This is my current scenario.

I have 2 same named directories in 2 different folders.
-------------------------------------------------
Server1

"/data/web_upload/data_27/" directory contains,
file1
file2
file3
SQL Directory
-------------------------------------------------
Server2

"/mnt/web_upload/data_27/" directory contains,
file1
file2
file4
SQL Directory
-------------------------------------------------
So, it is clear that file1,file2 & SQL Directory - common on both directories.

Now, please let me know how to merge all data without overwriting existing files & directories?

Thanks,
Nishith Vyas.
 
Old 09-24-2009, 01:57 AM   #10
nishith
Member
 
Registered: Aug 2008
Posts: 148

Original Poster
Rep: Reputation: 15
Smile True.

Yes.

You are right. I have to install "rsync" on both sides. but, is there any way available to "sync" data without having rsync on remote server?

Kindly Respond.

Nishith.
 
Old 09-24-2009, 07:37 AM   #11
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place.

I have merged your two virtually-duplicate threads into one.

Sasha
 
Old 09-24-2009, 08:06 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
1. make a backup copy of files on server1

2. use scp to copy dirs/files from eg server 2 to server 1, under a new dir eg server2/mnt/web_upload/data_27/

3. use the concept provided in posts #2, #4 to compare/merge files.

4. if needed, scp new fileset back to server2

5. if this is a problem that arises repeatedly, use the rsync or unison tool to keep the 2 systems synced.
 
Old 09-25-2009, 12:15 AM   #13
saifkhan123
Member
 
Registered: Apr 2009
Distribution: Red Hat/CentOS
Posts: 108

Rep: Reputation: 19
@topic

wht type of files are in "/data/web_upload/data_27" directory???and why do you need to merge the 2 directories???
 
  


Reply



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
merge directories d-fens Linux - General 9 02-04-2010 05:48 PM
How to merge two directories without losing data riteshanand40 Linux - Newbie 1 05-18-2009 06:17 AM
LXer: KHTML Vs Webkit: To Merge or Not To Merge LXer Syndicated Linux News 0 10-27-2007 06:41 AM
merge directories ryedunn Linux - Newbie 4 11-15-2006 09:02 AM
how do I Merge 2 directories syssyphus Linux - General 4 01-21-2006 02:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:07 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration