cpio deleting source files. Can't figure out why!


 
Thread Tools Search this Thread
Operating Systems HP-UX cpio deleting source files. Can't figure out why!
# 1  
Old 07-26-2012
cpio deleting source files. Can't figure out why!

So I ran into a strange problem the other day when using cpio. I'm not really sure this needed to be in an HPUX specific forum, but wasn't sure where else to put it. I'm running HPUX 11.11 PARISC.

I was using cpio to copy a directory and its entire contents from one server, we'll call it server A, to another server, we'll call it server B, via an NFS mount.

Server A is exporting /source/dir, and server B is mounting it as a client, mounting it as /nfs/source/dir. My current working directory on server B was /nfs/source/dir. As you can see, I am trying to copy all the contents of /nfs/source/dir into /dest/dir. here is the command I ran, sitting inside /nfs/source/dir:

Code:
find . | cpio -pmduv /dest/dir/.

It copied all the files to the destination directory just fine, but after it did that it prompted me with a message asking if it's ok to delete a file. I wasn't sure what file it was referencing, but I didn't want to delete anything, so I told it no, and it went on to ask me about more files. I cancelled out of it. Well it seems that it deleted some files without prompting me before I got the first prompt. (I think permissions of some files allowed it to delete without prompting me)

Why would cpio remove files from the source after the copy was done?

I found a couple links referencing a similar issue, but I'm not doing it the same way as either of them. Here are the links in case you're curious:
[TCLUG] cpio bug?
[Bug-cpio] CPIO can also delete the files from destination location.

I tried reproducing the problem in a test directory and couldn't do it. Even using the methods used in those links, (which are very old), I couldn't get it to replicate the problem. I did get it to give me an error saying that it couldn't copy from one directory to the same directory, when trying to basically copy from one directory back to itself, but it certainly didn't try deleting anything, and it's not even close to the command I was running.

Any ideas as to why this would happen?

Last edited by paqman; 07-26-2012 at 06:32 PM..
# 2  
Old 07-26-2012
My system doesn't have this -u option, what's it do on yours?
# 3  
Old 07-26-2012
The second link is GNU specific - you're running on HP-UX....
# 4  
Old 07-26-2012
Quote:
Originally Posted by Corona688
My system doesn't have this -u option, what's it do on yours?
The u does an unconditional file copy. In other words, normally, cpio would only copy changed files. The u tells it to copy everything, no matter what. I did that because I had a large number of files in the destination dir already, and wanted everything overwritten fresh.


Quote:
Originally Posted by vgersh99
The second link is GNU specific - you're running on HP-UX....
Ah, you're right. Oh well, moot point, didn't help anyway.
# 5  
Old 07-26-2012
First lose the dot in the destination directory name and use the command in the manner described in man cpio plus an nfs-specific parameter:
Code:
find . -xdev -depth -print | cpio -pmduv /dest/dir

I have never heard of cpio asking about deleting source files.
Make sure that you don't have either a script or alias which clashes with the commands:
Code:
type cpio
type find


Last edited by methyl; 07-26-2012 at 07:32 PM.. Reason: typo
# 6  
Old 07-26-2012
Quote:
Originally Posted by methyl
First lose the dot in the destination directory name and use the command in the manner described in man cpio plus an nfs-specific parameter:
Code:
find . -xdev -depth -print | cpio -pmduv /dest/dir

I have never heard of cpio asking about deleting source files.
Make sure that you don't have either a script or alias which clashes with the commands:
Code:
type cpio
type find

Well the dot in the destination wasn't originally there, and it doesn't seem to make a difference. I've since tried tests with and without it, and can't replicate the problem.

Neither cpio or find have any other scripts clashing with them, the type command finds them both in /usr/bin.

The tests I'm currently running are also over NFS, and I can't replicate the problem, no matter how I type the command. Is it possible that a file in the source dir caused it?
# 7  
Old 07-26-2012
Quote:
Well the dot in the destination wasn't originally there
Accuracy and full factual data is essential to diagnose this sort of fault.

First check that you do not have . in $PATH. This can give trouble if any executable file in the current working directory has the same name as a system command. If in doubt use absolute path names for commands in system scripts or set a custom $PATH specific to the script.

Incorrect use of asterisk characters in a command is more likely, and you probably ran some cleanup script by mistake.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Cpio - input files (from list) are stored in different order inside cpio archive - why?

Due to budget constraints I have to reinvent an Enterprise backup system in a SPARC (sun4v) Solaris estate (10 & 11). (yep - reinvent wheel, fun but time consuming. Is this wise?! :confused: ) For each filesystem of interest, to try to capture a 'catalog' at the front of each cpio archive (for... (1 Reply)
Discussion started by: am115998
1 Replies

2. Shell Programming and Scripting

Cpio all *.txt-files out of folders to just one directory

I need a hint for reading manpage (I did rtfm really) of cpio to do this task as in the headline described. I want to put all files of a certain type, lets say all *.txt files or any other format. Spread in more than hundreds of subdirectories in one directory I would like to select them and just... (3 Replies)
Discussion started by: 1in10
3 Replies

3. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

4. Shell Programming and Scripting

Help with change significant figure to normal figure command

Hi, Below is my input file: Long list of significant figure 1.757E-4 7.51E-3 5.634E-5 . . . Desired output file: 0.0001757 0.00751 0.00005634 . . . (10 Replies)
Discussion started by: perl_beginner
10 Replies

5. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

6. Shell Programming and Scripting

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

7. HP-UX

cpio.cat.z files????

what are cpio.cat.z files??? Can I delete them??? (3 Replies)
Discussion started by: ldaliosmane
3 Replies

8. Red Hat

Method to Unpack cpio files

Hi all, I want to unpack some files .Files and their sizes are: 1. Linux9i_Disk1.cpio -- 500m 2. Linux9i_Disk2.cpio--- 600m 3.Linux9i_Disk3.cpio---- 250m I used cpio -idmv Linux9i_Disk1.cpio command to unpack the files. But Its taking more time to unpack the files.What could be the... (2 Replies)
Discussion started by: William1482
2 Replies

9. Shell Programming and Scripting

cpio - files > 2gb

Hi, Currently a backup script copies compressed files to tape using cpio command (on AIX 5.2). Recently we've had a compressed file which has gone over 2 GB in size resulting in an error while copying this file onto the tape using cpio. Any suggestions on relevant workarounds would be much... (2 Replies)
Discussion started by: dnicky
2 Replies

10. AIX

cpio - files > 2 GB

Hi, Currently a backup script copies compressed files to tape using cpio command (on AIX 5.2). Recently we've had a compressed file which has gone over 2 GB in size resulting in an error while copying this file onto the tape using cpio. Any suggestions on relevant workarounds would be much... (0 Replies)
Discussion started by: dnicky
0 Replies
Login or Register to Ask a Question