LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 11-05-2009, 05:45 PM   #1
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Rep: Reputation: 30
Copy a directory without it's contents?


Is there a way to copy a directory (retaining the permissions and owners) without copying the contents of the directory?

If there is no such thing... then I need a way to determine if a target path is a file or a directory, and if it is a directory I need to make a new directory elsewhere that has the same name, owner and permissions.

Any ideas on a good way to do this?


Basically, I'm trying write a script to copy 200 GB of files over a network to a new server, and I'd like to do it by generating a list with the find command. That way, I can migrate large chunks of the files over the course of a week, and on the day of the migration generate a new list of files that changed in the last week and then copy just the chagned files over minimizing the down time. However, the list will contain directories that I can't just use the 'cp' command on because it will copy all the contents of the directory.
 
Old 11-05-2009, 05:48 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Copy your chunks over the course of a week, but then use "rsync" to do the final cleanup. "rsync" will only copy files that have changed.
 
Old 11-05-2009, 06:05 PM   #3
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 30
hmm, I'll have to look into that. looks like I might be trying to reinvent the wheel here
 
Old 11-05-2009, 06:58 PM   #4
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 30
omg... rsync is awesome. files are transferring as we speak

god I love *nix systems
 
Old 11-05-2009, 09:45 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Quote:
Originally Posted by davidstvz View Post
omg... rsync is awesome. files are transferring as we speak

god I love *nix systems
Just hit the little thumbs up button, if you don't mind.
 
Old 11-06-2009, 03:03 AM   #6
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 30
don't mind at all! the last files are transferring now

In case anyone is tracing my footsteps in the future, here are some helpful details. Once the rsync server was running on the new debian machine (which was automatic just by installing it using apt-get), I used the following command from the old server (which already had rsync):

rsync -r -H -p -o -g -t -v -e ssh /home root@target.server.com:/

-r = recursive copy
-H = copy hard links
-p = retain permissions
-o = retain owner
-g = retain group
-t = retain time stamps
-v = verbose
-e ssh = encrypt with ssh
/home = the directory you wish to transfer (can be a full path)
root@target.server.com = log on to targer.server.com as root user
:/ = this means to transfer the files to the root directory of the target server

Since /home goes in the root directory, targeting / works. If you had to copy a more specific directory such as /home/user25 you would want the last part to say /home
 
  


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
Copy a directory without contents zefram Linux - Software 2 04-28-2009 06:06 PM
How to copy entire contents brick_46143 Linux - Newbie 15 02-27-2008 12:46 PM
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 05:02 AM
How can I copy a directory and it's contents with CLI? CyberLord_7 Linux - General 2 03-30-2004 12:35 PM
Copy contents of one partition to another. cparker15 Linux - Software 1 06-26-2003 02:17 PM


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

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