LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 04:45 PM   #1
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Rep: Reputation: 31
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, 04:48 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
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, 05:05 PM   #3
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

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

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

god I love *nix systems
 
Old 11-05-2009, 08:45 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
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, 02:03 AM   #6
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:39 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