Restoring a directory using cpio command?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Restoring a directory using cpio command?
# 1  
Old 04-04-2004
Restoring a directory using cpio command?

I am confused with how to restore archives. I just figured out the use of tar, but now after trying it with cpio, I'm unsure of some things. Firstly, is it necessary to cd to the directory you will be restoring to in order to run this command?
Secondly, what is it I'm doing wrong when trying to restore an archive into an empty directory?

$ cpio -ivdu backup.cpio < cpio-restore

backup.cpio is a file and cpio-restore is a directory

I am getting the following error:

cpio: read error: Is a directory

Thank you
# 2  
Old 04-04-2004
cpio is perhaps bemusingly complex when you're first figuring out how to use it.

According to the syntax you've used there, you're trying to make the shell supply the directory to cpio as an input on stdin.

You might try:

cat backup.cpio | cpio -iumd .

This should pipe in the cpio file to cpio which accepts it as an input ( -i ) and reconstructs the file contents in the "." (the current directory). A word of warning though, always make cpio archives with _relative_ paths, not absolute ones or you're asking for trouble.
# 3  
Old 04-04-2004
Thanks for the info nitrile. Believe it or not, I had just figured that out for myself, and I was just coming back here to tell everyone never mind.

Thanks again!
 
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. Solaris

About cpio command

i need to extract cpio file archived full path to /restore/ (not full path or fullpath under this directory ) i can't find option for cpio please help me example. i have cpio file archive /etc/* and i need to extract file to /restore #cpio -ivBcdmu < xx.cpio but data from cpio not... (3 Replies)
Discussion started by: infjustice
3 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. UNIX for Dummies Questions & Answers

Using cpio with the find command

Hey everyone, I’ am a newbie to Unix. Learning some of the basic commands. I did some piping before like who | wc I wanted to practice some backup features in Unix. I’ am practicing using cpio and place it into a file named backup. I’m not quite sure where I’ am going wrong? ... (1 Reply)
Discussion started by: fox987
1 Replies

6. UNIX for Dummies Questions & Answers

advantages of cpio command?

hi, can any body tell me the advantages of having cpio command over tar command (7 Replies)
Discussion started by: prasannak
7 Replies

7. UNIX for Advanced & Expert Users

restoring backup using tar command

Please help me in resolving the issue. I have taken backup using the below command $ tar cvf - . |compress -> /opt/globusback2/needed_backups/apglsg.tar.Z I tried to restore the backup using the below command. $ zcat /opt/globusback2/needed_backups/apglsg.tar.Z | tar -xvf - ... (5 Replies)
Discussion started by: amirthraj_12
5 Replies

8. UNIX for Dummies Questions & Answers

restoring backup using tar command

Please help me in resolving the issue. I have taken backup using the below command $ tar cvf - . |compress -> /opt/globusback2/needed_backups/apglsg.tar.Z I tried to restore the backup using the below command. $ zcat /opt/globusback2/needed_backups/apglsg.tar.Z | tar -xvf - ... (2 Replies)
Discussion started by: amirthraj_12
2 Replies

9. Filesystems, Disks and Memory

Restoring back files from "lost+found" directory

Hi Friends, How can I Restore the Files present under "lost+found" Directory of a FileSystem (in Solaris & Tru64 OS) to their original Locations. Now-a-days I am loosing lots of files in 2 of my Machines, One running Solaris8 and other Tru64(Digital) Unix. Thanx in... (1 Reply)
Discussion started by: dhasarath
1 Replies

10. UNIX for Dummies Questions & Answers

cpio command with compress

Hi friends.. I want to be able to copy a file from one location to another (locally). The location the files are copied to should have compressed instances of the files they were copied from. copy from /home/user/test.file copy to /backup/user/test.file.Z I need to be able to do this... (1 Reply)
Discussion started by: sureshy
1 Replies
Login or Register to Ask a Question