I am backing up files including directories from 1 partition to other using cpio
. cpio
works perfect for backing but I am unable to backup directory tree. I am in a partition mounted on the directory as shown below. In that partition, I am in the directory /b/c
. It contains 3 files 'd, e & f'. Also it contains a directory named g which in turn includes files 'h & j'. Please see below.
ravbholua@ravbholua-Aspire-5315:/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c$ ls *
d e f
g:
h j
Now I want to back up all these files (d, e, f, h & j) including directory structure on to a different partition. I have created file (or archive in this case) named 'mark'. Please see below. Using cpio
I am transferring to archive named 'mark'.
ravbholua@ravbholua-Aspire-5315:/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c$ ls -R /med*/ravb*/*36/b/c/* | cpio -ov > /med*/ravb*/*9f/mark
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/d
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/e
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/f
cpio: blank line ignored
cpio: /media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/g:: Cannot stat: No such file or directory
cpio: h: Cannot stat: No such file or directory
cpio: j: Cannot stat: No such file or directory
1 block
ravbholua@ravbholua-Aspire-5315:/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c$
cpio
perfectly transferred the immediate files (d, e & f) in the directory. Problem comes for the directory g and the subdirectory files. It's apparent that cpio
requires regular files and doesn't entertain directory. So, now so that the tool cpio
includes the directory tree, anyhow I have to give cpio the subdirectory files 'h & j' under directory 'g'. How to do that.
ls, ls -R, etc.
can't provide only the files in their output, they include directory also.
So, please tell me is there any option to ls or any other command that will output only the files in the directory tree. Have a look below:
$ (command that will output the below)
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/d
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/e
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/f
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/g/h
/media/ravbholua/c09fb098-0402-418a-b1e5-8888848a5636/b/c/g/j
EDIT
I'm editing my Q with some correction so that any viewer of this thread would get clear and right information. I mentioned that cpio
doesn't accept directories based on what I felt from the output of ls
command. But its wrong. cpio
accepts directories even. So, cpio
to me seems to be a very great tool for backing up selected files or complete partition/disk.