LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-21-2012, 04:32 PM   #1
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Rep: Reputation: 60
CPIO --no-absolute-filenames


I succesfully created a backup script that creates CPIO archives preserving access times and etc. I orginally created the CPIO archives using the absolute paths.

Code:
find / -depth | grep -f include| cpio -oavc | gzip > archive.cpio.gz
I am trying to extract a cpio archive into a temp directory to check to make sure things are backing up and things are ok but am having trouble because it complains about permissions and will not restore in the current directory. So

Code:
mkdir /home/testuser/extract
cd /home/testuser/extract
user@extract>gunzip archive.cpio.gz
-rw-rw-r-- 1 tester testuser 1314521600 2012-02-21 13:21 archive.cpio
user@extract>cpio -i --no-absolute-filenames < 10.7.0.180.cpio
cpio: var/lib/dpkg/info/libgnome-bluetooth7.md5sums: Cannot open: Permission denied
cpio: var/lib/dpkg/info/humanity-icon-theme.postrm: Cannot open: Permission denied
cpio: var/lib/dpkg/info/libmono-system2.0-cil.md5sums: Cannot open: Permission denied
cpio: var/lib/dpkg/info/telepathy-butterfly.preinst: Cannot open: Permission denied
cpio: var/lib/dpkg/info/ufw.md5sums: Cannot open: Permission denied
cpio: var/lib/dpkg/info/tsconf.list: Cannot open: Permission denied
cpio: var/lib/dpkg/info/acpid.md5sums: Cannot open: Permission denied
cpio: var/lib/dpkg/info/libstdc++6.shlibs: Cannot open: Permission denied
cpio: var/lib/dpkg/info/libavc1394-0.postinst: Cannot open
????

Last edited by metallica1973; 02-21-2012 at 04:34 PM.
 
Old 02-21-2012, 04:48 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
In my case (I ran your commands against /var/log as a source), I had to --make-directories at the target:

Code:
cpio -i --no-absolute-filenames --make-directories < archive.cpio
Any help?
 
Old 02-21-2012, 04:50 PM   #3
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Original Poster
Rep: Reputation: 60
Thanks for your reply. I had an IDIOT moment:

Code:
cpio -idmv --no-absolute-filenames < 10.7.0.180.cpio
-i extract
-d create leading directories where needed
-m retain previous file modification times when creating files
-v verbose

Last edited by metallica1973; 02-21-2012 at 08:04 PM.
 
Old 02-13-2015, 10:10 AM   #4
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Original Poster
Rep: Reputation: 60
This is simply an add on to this post if someone would like to extract a single file from a cpio file.

My preferred way:
PHP Code:
sudo cpio -icdmv --no-absolute var/spool/cron/test <test011715.cpio
ls 
-ltr
drwxrwxr
-x  2 testuser testuser     4096 Jan 14 13:36 var 
and a secondary way using a file to specify what you want to extract:
PHP Code:
cat tmpfile
var/spool/cron/test
sudo cpio 
-idmv --no-absolute-filename -E tmpfile <test011715.cpio
ls 
-ltr
drwxrwxr
-x  2 testuser testuser     4096 Jan 14 13:36 var
-
rw-rw-r--  1 testuser testuser    10000 Jan 15 13:23 tmpfile 
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CPIO archive with absolute paths- extraction to a different directory? sonichedgehog Linux - Software 3 11-23-2011 10:02 AM
script help - add absolute path to list of filenames greengrocer Linux - Newbie 7 10-12-2008 05:23 AM
LXer: Absolute Linux is an absolute winner LXer Syndicated Linux News 0 08-07-2007 07:32 PM
TFTP Error #2: Only absolute filenames allowed + remove regular file VampireL0rd Fedora 1 07-19-2007 04:37 PM
'cat' not allowing absolute filenames when piped to 'cut' d3funct Programming 6 12-06-2002 03:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration