General
cancel
Showing results for 
Search instead for 
Did you mean: 

create tar-ball from a file containing listing of what to tar

SOLVED
Go to solution
Mark Ellis
Advisor

create tar-ball from a file containing listing of what to tar

I want to tar-ball some files into a mounted NFS shared drive. If I have a file called "/root/files_to_move" that contains the absolute path names of files I want to move - how can I tar them up and push them into this nfs mounted file system?

tar cvf - | cd ; tar xvf -

Thanks!!!
8 REPLIES
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: create tar-ball from a file containing listing of what to tar

While you could untar with pax to override the absolute pathnames; by far, the easist solution is to tar the files with relative pathnames even if that really means cd'ing to "/" and starting all your relative pathnames with "./". One of the lessons you eventually learn is to never tar anything as absolute paths.
If it ain't broke, I can fix that.
TwoProc
Honored Contributor

Re: create tar-ball from a file containing listing of what to tar

tar cvf - `cat /root/files_to_move` | cd ; tar xvf -

or since the file list has absolute path names...

cd /folder_to_move_them_to
tar cvf - `cat /root/files_to_move` | tar xvf -
We are the people our parents warned us about --Jimmy Buffett
Leif Halvarsson_2
Honored Contributor

Re: create tar-ball from a file containing listing of what to tar

Hi,
I am not sure I understand the problem, why not use cpio -p instead.
Mark Ellis
Advisor

Re: create tar-ball from a file containing listing of what to tar

Leif, How would the sytax go with cpio and the "-p" option?
A. Clay Stephenson
Acclaimed Contributor

Re: create tar-ball from a file containing listing of what to tar

Oh, and to read the list of files:
tar cvf - $(cat /root/files_to_move)
If it ain't broke, I can fix that.
TwoProc
Honored Contributor

Re: create tar-ball from a file containing listing of what to tar

re: cpio ...
what might/should work is ...
cat files_to_move | cpio -pdmvu /folder_to_move_to
We are the people our parents warned us about --Jimmy Buffett
harry d brown jr
Honored Contributor

Re: create tar-ball from a file containing listing of what to tar

Why use tar?

cat /root/files_to_move | xargs -i cp -rp {} /someNFSmount

live free or die
harry d brown jr
Live Free or Die
Mark Ellis
Advisor

Re: create tar-ball from a file containing listing of what to tar

I am close, but not there yet... The list I want to move over is too large for "cat", so that is issue number 1. The other issue is that the mounted file system I want to move the files to have to have the full path under that file system.

Example:

box1:
I want to move /etc/hosts to box2 under the mounted file system /backup as /backup/etc/hosts.

box1 mounts box2's /backup file system as local mountpoint /backup.

I am still having issues - HELP!