Main BLOGGER
Google
WWW THIS BLOG
Thursday, February 15, 2007
 
Linux: Copy Files
1. http://www.sun.com/bigadmin/content/submitted/safely_copy_files.html
2. http://www.cs.hmc.edu/qref/targzip.html
3. http://www.unixtips.org/
4. http://www.linux.com/guides/abs-guide/

cp -r or cp -a might not be appropriate in some cases.
1. NFS (might be a partial copy)
2. symbolic links (will copy the actual content)
3. file group and permission (will lose)

An alternative could be using tar (from http://www.linux.com/guides/abs-guide/)

(cd /source/directory && tar cf − . ) | (cd /dest/directory && tar xpvf −)


# Move entire file tree from one directory to another
# [courtesy Alan Cox <a.cox@swansea.ac.uk>, with a minor change]
# 1) cd /source/directory
# Source directory, where the files to be moved are.
# 2) &&
# "And−list": if the 'cd' operation successful,
# then execute the next command.
# 3) tar cf − .
# The 'c' option 'tar' archiving command creates a new archive,
# the 'f' (file) option, followed by '−' designates the target file
# as stdout, and do it in current directory tree ('.').
# 4) |
# Piped to ...
# 5) ( ... )
# a subshell
# 6) cd /dest/directory
# Change to the destination directory.
# 7) &&
# "And−list", as above
# 8) tar xpvf −
# Unarchive ('x'), preserve ownership and file permissions ('p'),
# and send verbose messages to stdout ('v'),
# reading data from stdin ('f' followed by '−').
#
# Note that 'x' is a command, and 'p', 'v', 'f' are options.
#
# Whew!

You can also use a tar pipe to copy across the network:

(cd /source/directory && tar cf − . ) | ( ssh server 'cd /dest/directory && tar xpvf −' )

--
Pop (Pu Liu)



<< Home

Powered by Blogger

Google
WWW THIS BLOG