Re: Copying a whole subdirectory possible?
On Sat, Jan 19, 2002 at 07:01:27PM -0600, Manoj Srivastava wrote: Hi, The short answer is: # cd /path/to/old/directory # find . -depth -print0 | afio -p -xv -0a /mount/point/of/new/directory [ snip ] afio: Afio is a better way of dealing with cpio-format archives. It is generally faster than cpio, provides more diverse magnetic tape options and deals somewhat gracefully with input data corruption. It deals somewhat gracefully with input data corruption. Supports multi-volume archives during interactive operation. Afio can make compressed archives that are much safer than compressed tar or cpio archives. Afio is best used as an `archive engine' in a backup script. % find . -depth -print0 | afio -px -0a new-dir All my backups onto tape use afio. Are you interested in sharing your backup scripts? I just put a dds-3 in a server here and I'm lookng to put it to use. -- Nathan Norman - Staff Engineer | A good plan today is better Micromuse Ltd. | than a perfect plan tomorrow. mailto:[EMAIL PROTECTED] | -- Patton pgpqYmbgPzYbL.pgp Description: PGP signature
Re: Copying a whole subdirectory possible?
On Fri, Jan 11, 2002 at 05:52:55PM -0800, Tim locke decreed: I need to copy a whole subdirectory to another subdirectory...possible? (i.e. cp /home/user1/file /home/user2/file) as a regular user. ---end quoted text--- For the most accurate reproduction of a directory tree consider using the tar command: tar cf - . | (cd $1; tar xvf -) The command above assumes you want to copy from the working directory to another that replaces the $1 symbol. The advantage of tar is that it preserves permissions, links, etc. perfectly. cp does not make as perfect a copy. The attached script is a wrapper for the tar command above that will prompt to create the target directory, etc. Caveat - use at your own risk. But there's not much to it, and I use it all the time. Cheers, Steve -- \_O \_O \_O ~~~ Steve Cooper Redmond, WA #!/bin/sh function yesno() { typeset yn echo -n $1 (y/N)? read yn typeset -i b if [ $yn = y -o $yn = Y -o $yn = yes ] then return 0 else return 1 fi } typeset -i nf if [ $# -ne 1 ] then echo Usage: tarclone destination directory exit 1 fi if [ ! -d $1 ] then echo Destination \$1\ does not exist if ( yesno Create it ) then mkdir $1 else exit 2 fi fi nf=$('ls' $1 | wc -l) if [ $nf -ne 0 ] then echo Destination \$1\ is not empty if ( yesno Copy anyway ) then echo Overwriting \$1\ else exit 3 fi fi echo -n Ready to clone $(pwd) to $1 (y/N)? read yn if [ $yn = y -o $yn = Y -o $yn = yes ] then tar cf - . | (cd $1; tar xvf -) fi
Re: Copying a whole subdirectory possible?
Steve Cooper wrote: For the most accurate reproduction of a directory tree consider using the tar command: tar cf - . | (cd $1; tar xvf -) I always thought that: tar cf - . | (cd $1; tar xpvf -) was the correct way. The one time I forgot the -p during extraction, I had permission problems with several files in /dev. Or maybe that was caused by some other mistake I made. -- David Raeker-Jordan mailto:[EMAIL PROTECTED] Harrisburg, PA, USA
Re: Copying a whole subdirectory possible?
Hi, The short answer is: # cd /path/to/old/directory # find . -depth -print0 | afio -p -xv -0a /mount/point/of/new/directory Now for the long answer. The candidates are: cp: Traditionally, cp was not really a candidate since it did not derenference symbolic links, or preserve hard links either. Another thing to consider was sparse files (with holes). GNU cp has overcome these limitations, however, on a non GNU system, cp could still have problems. Also, you can't genrate small, portable archives using cp. % cp -a . newdir tar: Tar overcame some of the problems that cp had with symbolic links. However, `cpio' handles special files; traditional `tar' doesn't. `tar's way of handling multiple hard links to a file places only one copy of the link on the tape, but the name attached to that copy is the _only_ one you can use to retrieve the file; `cpio's way puts one copy for every link, but you can retrieve it using any of the names. % tar cf - . | (cd new-dir; tar xvvSpf -) pax; The new, POSIX (IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940 (section E.4.48)), all singing, all dancing, Portable archive interchange utility. pax will read, write, and list the members of an archive file, and will copy directory hierarchies. pax operation is independent of the specific archive format, and supports a wide variety of different archive formats. pax implementations are still new and wet behind the ears. % pax -rw -p e . newdir or % find . -depth | pax -rw -p e newdir cpio: copies files into or out of a cpio or tar archive, The archive can be another file on the disk, a magnetic tape, or a pipe. % find . -depth -print0 | cpio --null --sparse -pvd new-dir afio: Afio is a better way of dealing with cpio-format archives. It is generally faster than cpio, provides more diverse magnetic tape options and deals somewhat gracefully with input data corruption. It deals somewhat gracefully with input data corruption. Supports multi-volume archives during interactive operation. Afio can make compressed archives that are much safer than compressed tar or cpio archives. Afio is best used as an `archive engine' in a backup script. % find . -depth -print0 | afio -px -0a new-dir All my backups onto tape use afio. manoj -- Noncombatant: A dead Quaker. Ambrose Bierce Manoj Srivastava [EMAIL PROTECTED] http://www.debian.org/%7Esrivasta/ 1024R/C7261095 print CB D9 F4 12 68 07 E4 05 CC 2D 27 12 1D F5 E8 6E 1024D/BF24424C print 4966 F272 D093 B493 410B 924B 21BA DABB BF24 424C
Re: Copying a whole subdirectory possible?
On Sunday 20 January 2002 1:01 am, Manoj Srivastava wrote: Hi, The short answer is: # cd /path/to/old/directory # find . -depth -print0 | afio -p -xv -0a /mount/point/of/new/directory Now for the long answer. The candidates are: What about rsync -- Alan - [EMAIL PROTECTED] http://www.chandlerfamily.org.uk
Re: Copying a whole subdirectory possible?
Tim locke wrote: I need to copy a whole subdirectory to another subdirectory...possible? (i.e. cp /home/user1/file /home/user2/file) as a regular user. How about cp -r? Or better yet: cp -a. Cheers, Viktor -- Viktor Rosenfeld WWW: http://www.informatik.hu-berlin.de/~rosenfel/ pgpVrzdPtFHs5.pgp Description: PGP signature
Re: Copying a whole subdirectory possible?
Tim locke [EMAIL PROTECTED] writes: I need to copy a whole subdirectory to another subdirectory...possible? (i.e. cp /home/user1/file /home/user2/file) as a regular user. ^ If you're getting access denied errors, you probably don't have write permission to directory user2... by default, different users don't have access to each other's home directories. To solve this problem, you can either make user2 world writeable (bad idea, especially if you're on a shared system) or you can create a special group -- you might call it friends or users or something to that effect -- and make user2 writeable to members of that group. man groupadd man usermod man chown You'll probably have to log out and back in again before the new group membership goes into effect. HTH
Re: Copying a whole subdirectory possible?
not access denied errors. I need to copy a subdirectory located in a public directory to my home directory...I can copy the files one by one but I'd rather copy the whole subdirectory itself to my home directory... __ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/
Re: Copying a whole subdirectory possible?
On Fri, Jan 11, 2002 at 07:35:11PM -0800, Tim locke wrote: not access denied errors. I need to copy a subdirectory located in a public directory to my home directory...I can copy the files one by one but I'd rather copy the whole subdirectory itself to my home directory... Have you tried 'cp -a directory1 directory2' ? Take a look at the cp man page. -- Ron Golan [EMAIL PROTECTED] GPG key http://people.we.mediaone.net/rgolan/gpg.asc
Re: Copying a whole subdirectory possible?
Have you tried cp -r path/dirname newpath ? -- Carl Fink [EMAIL PROTECTED] I-Con's Science and Technology Programming http://www.iconsf.org/