move files between file systems with privileges, time stamp


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers move files between file systems with privileges, time stamp
# 1  
move files between file systems with privileges, time stamp

Hi

I have to move files between file systems but files in new file system must have the same attributes as in old one (privileges, time stamp etc).

Which tool is best :
- ufsdump / ufsrestore
- tar
- cpio
- pax
- dd
- mv

Or maybe there is sth else, you suggest to use.

Thx for help
# 2  
Either cp with the '-p' ("preserve") option, or mv. Both should preserve the modification and access time and permission bits. For ACLs that should be preserved see the man page of your OS.
# 3  
with mv -p I agree but with cp -p I can't agree because it sets default perms.

what is the best practice for admins to move files between file systems ?
what kind of tool (cmd) ?
# 4  
In addition, look into the -p flag in both tar and scp (if your remote location has ssh running); it's fairly standard among utils, but these are my friends. Also, make sure that you're not bound to a different umask on the new location...if it differs, and you can't reset it as needed, you might be restricted to only what's available to the next machine.
# 5  
a) mv doesn't have a -p option
b) did you read the man page for cp?
Quote:
If dest_file was created, its file permission bits shall be changed (if necessary) to be the same as those of source_file, modified by the file creation mask of the user if the -p option was not specified.
That means you umask and other properties only apply if you don't specify '-p'.

Alternatively you could use cpio:
Code:
find /source -xdev -print | cpio -pdm /destination

# 6  
mv is ok, but if you get some sort of error halfway through it can be difficult to recover.

one of the fastest Ive found is (from source dir):
Code:
tar -cBpf - . | ( cd /dest ; tar -xBpf - )

It uses two processes, so they can be prioritized by the O/S (one for reading, one for writing) but it still moves the data through a pipe which just replicates data in memory and thus is not the most efficient.

scp will encrypt/decrypt and so put unnecessary load on the cpu.

cp -pr on machines like Solaris is pretty fast because it mmaps the files which means there is no duplication of the file data in memory - it is simply tagged by the o/s to be written directly to disk, so should be the most efficient. However if it isnt multithreaded it will waste time waiting for I/O.

I would personally do some tests of all of the above on your O/S using the unix "time" and see which one wins (dont just measure the real time but the system/cpu time as well)
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #467
Difficulty: Easy
In computer networking, telecommunication and information theory, broadcasting is a method of transferring a message to all recipients using reverse polish notation.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying multiple files and appending time stamp before file extension

Hi, I have multiple files that read: Asa.txt Bad.txt Gnu.txt And I want to rename them using awk to Asa_ddmmyytt.txt and so on ... If there is a single command or more efficient executable please share! Thanks! (4 Replies)
Discussion started by: Jesshelle David
4 Replies

2. Shell Programming and Scripting

Need Time Stamp Range On Log Files

I have created this script #!/bin/sh FILES=/data/log/access_*.log for f in $FILES do echo "Processing $f file" cat $f | awk '{print $1}' | sort | uniq -c | sort -n | tail done It produces this output Processing /data/log/access_abc.log file 114 1.1.1.1 167 2.2.2.2 ... (38 Replies)
Discussion started by: sharingsunshine
38 Replies

3. Shell Programming and Scripting

Files with date and time stamp

Hi Folks, Need a clarification on files with date and time stamp. Here is my requirement. There is a file created everyday with the following format "file.txt.YYYYMMDDHHMMSS". Now i need to check for this file and if it is available then i need to do some task to the file. I tried... (6 Replies)
Discussion started by: jayadanabalan
6 Replies

4. Shell Programming and Scripting

Select files by time stamp

Hi, I need help to read file in a directory on basis of time stamp. e.g. If file access in last 2 minutes it should not be copy to remote directory. Below is my script. +++++++++++++++++++++++++ #!/bin/ksh DATE=`date +"%Y-%m-%d_%H%M"` SEPARATER=" " exec < out_interfaces.cfg... (1 Reply)
Discussion started by: qamar.alam
1 Replies

5. Shell Programming and Scripting

Old time stamp being updated for new files

Hello Friends I am facing a weird problem :confused:, we receive thousands of files in my system on a daily basis, access time stamp on some of the files are being updated as old time stamp like 1968-01-19, Could some one help me what could be causing this? so that i can narrow down the problem... (4 Replies)
Discussion started by: Prateek007
4 Replies

6. Fedora

Move file based time stamp

Hi all, I've already tired to try to solved this problem. Also search in Internet didn't find anything solution I have a directory like this : # pwd /opt/projects/juventini # ls -al | more total 3627460 drwxr-xr-x 2 app apps 12472320 Sep 24 14:59 . drwxr-xr-x 11 app apps 4096 Jun... (8 Replies)
Discussion started by: sunardo
8 Replies

7. Shell Programming and Scripting

Move files one at the time and wait until the previous file is handled

I'm a novice at unix and need it more and more to do my work. I seem running into problems getting this script "attempt" to work: I need to copy all files in a directory, which is containing 22000 files, into a directory one level up. There a tool monitors the content of the dir and processes... (2 Replies)
Discussion started by: compasscard
2 Replies

8. Solaris

doubt reg time stamp in files.

I copied a file from one host to another using sftp. But after copying the time stamp is not updating . Even though I checked the permission, it looks good. I copied the same file to some temporary location, there it updating the time stamp. Anyone have any idea on this (6 Replies)
Discussion started by: rogerben
6 Replies

9. UNIX for Dummies Questions & Answers

Copy all the files with time stamp and remove header,trailer from file

All, I am new to unix and i have the following requirement. I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file.. Could... (35 Replies)
Discussion started by: ksrams
35 Replies

10. UNIX for Dummies Questions & Answers

Need to delete the files based on the time stamp of the file

Hi Everyone, I want to delete some files in a path based on the time stamp of the file that is i want to delete the file once in a month. Can any one help me on this? Thanks in advance (2 Replies)
Discussion started by: samudha
2 Replies

Featured Tech Videos