Cpio archive help


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cpio archive help
# 1  
Old 12-07-2015
Cpio archive help

Hi I'm new to the forum and looking for some help with cpio archive creation.

I have a bunch of directories that I need to make into a cpio archive.

The problem I'm having is that when I input the commands I get the cpio archive but it creates a duplicate of the archive inside the archive it's created

The command I'm using is

Code:
find . -print -depth | cpio -ov >archive_name

While it creates the archive with the directory structure I need I get a duplicate of archive_name inside the created archive.

I've tried using cpio from inside the directory and also from outside the directory.
When doing it from outside the directory it doesn't create the duplicate archive but creates the folder as the root directory which I don't want.

Any help would be appreciated as I've been trying for hours and know it's something silly I'm over looking

Last edited by Don Cragun; 12-07-2015 at 12:16 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 12-07-2015
As with another thread on this topic earlier today (Tar command fails), there are two easy ways to do this. Either move the output file out of the directories being archived:
Code:
find . -depth | cpio -ov >../archive_name

or exclude the output file from the list of files being archived:
Code:
find . -depth ! -name archive_name | cpio -ov >archive_name

# 3  
Old 12-07-2015
Thanks

I will give it a go.
I'm very grateful of you taking the time to reply if the question was already asked earlier in the day.

I must admit I didn't really search as I had been banging my head against a wall for a good few hours with it and being a newbie when it comes to these things was rather frustrated.

Many thanks again.
I'm sure I'll be asking lots more questions in the days to come
# 4  
Old 12-07-2015
Note that based on the discussion in the other thread I mentioned, if you use the 2nd approach I suggested in post #2, you may need to create the output file before you start the find to keep find from failing because the directory hierarchy is changing while it is reading it. In other words:
Code:
touch archive_name; find . -depth ! -name archive_name | clio -ov > archive_name

# 5  
Old 12-07-2015
Thanks

I'll bare that in mind. Although the second option seemed to work fine as is.

The problem I'm facing is somewhere along the lines I seem to have missed or been unable to find the trailer file for the first archive.

Its a firmware file that has been decompressed and extracted and revealed 2 cpio archives within it.
The second archive I am yet to look at but I think the trailer file is there for that archive
 
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

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

3. Shell Programming and Scripting

Appending a CPIO to an existing archive

I created a CPIO archive I wanted to add addition data to it but am having issues: -rw-r--r-- 1 test test 629295104 2011-10-28 12:41 /home/test/Downloads/test.cpio I tried: sudo find /tmp -depth | cpio -oAO /home/test/Downloads/test.cpio cpio: premature end of file and (1 Reply)
Discussion started by: metallica1973
1 Replies

4. UNIX for Dummies Questions & Answers

Unable to restore cpio archive to a directory

Hello Every one, I want to back up all passwd files to /xyz/passfiles.cpio and Then restore them to /abc directory. Here is what I wrote: find / -name passwd | cpio -oc > /tmp/passwd.cpio and to restore cd abc cpio -ium < /tmp/passwd.cpio I can not find the files restored to /abc... (2 Replies)
Discussion started by: drdigital_m
2 Replies

5. Shell Programming and Scripting

Extracting from archive | compressing to new archive

Hi there, I have one huge archive (it's a system image). I need sometime to create smaller archives with only one or two file from my big archive. So I'm looking for a command that extracts files from an archive and pipe them to another one. I tried the following : tar -xzOf oldarchive.tgz... (5 Replies)
Discussion started by: chebarbudo
5 Replies

6. UNIX for Dummies Questions & Answers

Selective restore from a cpio tape archive

Hi, I use following command to restore data from my cpio tape archive: $cpio -icvd < /dev/rct0 But this'll restore all tape contents to the current path, what if I want only selected files from the tape, suppose I want /home/compdir/home2/Rev83/data/PL/01/*.* files to be restored... (8 Replies)
Discussion started by: tayyabq8
8 Replies

7. HP-UX

Please help with cpio on HP-UX

Hello all ... I am an Oracle DBA that got stuck in a HP-UX SA role and need some help figuring out a UNIX problem. According to Oracle documentation, I am to issue the following command ... cpio -idcmv <file_name> However when I do, the server just hangs there and does nothing til I... (3 Replies)
Discussion started by: soestx
3 Replies

8. UNIX for Dummies Questions & Answers

cpio

Hello, how can I restore files from a DAT using CPIO ? If I make : # mkdir save # cd /save # cpio -icumvdB </dev/rct0 Does the archive restore only in the directory /save ? And how can I restore a specified file from the DAT with the cpio command ? How can I know the size of the... (2 Replies)
Discussion started by: kok
2 Replies

9. UNIX for Dummies Questions & Answers

Help with cpio

Hi all, Please help me with the extraction of files from a cpio. what I mean is basically I have received a file from someone i.e rooh.cpio. this file rooh.cpio contains various files in it. I want to know how I can extract the files and copy them to a different directory . Your quick... (2 Replies)
Discussion started by: rooh
2 Replies

10. UNIX for Dummies Questions & Answers

cpio

by mistake I deleted all the files in /usr2/symix/users/wfpsys/tpsc/ directory. full backup has taken yesterday using "CPIO" command and I am able to view the files from tape also using cpio command. but i couldn't able to restore back the files. Can you please help me immeditely by giving the... (2 Replies)
Discussion started by: wipro fluid power
2 Replies
Login or Register to Ask a Question