LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-21-2011, 11:53 AM   #1
blainemiller
Member
 
Registered: Dec 2003
Posts: 78

Rep: Reputation: 1
command for tar'ing multiple sub-directories into a single tar file


Hello,

I'm trying to move an entire subdirectory with it's associated files and subdirectories from one server to another using scp. I'm told one way to do this is to tar the subdirectory into a single .tar file.

I've seen examples of the command to tar up multiple single files into a single .tar file. I've not seen an example of how to do this to a full subdirectory and it's associated subdirectories into a single .tar file.

for example, if I wanted to tar a subdirectory called /main and all its subdirectories and files into a single file called main_backup.tar would I execute:

tar -cvf main_backup.tar /main

or

tar -cvf main_backup.tar /main/

or

tar -cvf main_backup.tar /main/*

???

Thanks! I appreciate your time and consideration.


Blaine
 
Old 04-21-2011, 12:56 PM   #2
eager
Member
 
Registered: Aug 2004
Location: Palo Alto, CA
Distribution: Fedora 8/9, Ubuntu
Posts: 50

Rep: Reputation: 18
tar -cvf main_backup.tar /main

This will create a tar file with everything in /main and any subdirectories.
Tar will remove leading slashes when it creates the tar file. This makes it easier to restore the directory tree at a different location.
 
Old 04-21-2011, 01:55 PM   #3
blainemiller
Member
 
Registered: Dec 2003
Posts: 78

Original Poster
Rep: Reputation: 1
Hi, Mike...

That didn't seem to work... I keep getting an error message:


tar -cvf /tmp/main2_backup.tar /main2
tar: Removing leading `/' from member names
tar: /main2: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
[root@mmeng tmp]# tar -cvf main2_backup.tar /main2
tar: Removing leading `/' from member names
tar: /main2: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors


Any thoughts?

Thanks!

Blaine
 
Old 04-21-2011, 02:05 PM   #4
blainemiller
Member
 
Registered: Dec 2003
Posts: 78

Original Poster
Rep: Reputation: 1
Found it... I just needed to prefix the ../main2 with the upper level directory or /tmp/main2 and it worked...

Thanks!

Blaine
 
  


Reply

Tags
tar


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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
need help with tar'ing and bz2'ing a file surfbass Linux - General 4 06-01-2005 05:07 PM
TAR'ing multiple directories bob_man_uk Linux - Software 3 02-03-2005 11:08 AM
tar multiple directories computera Linux - General 2 11-17-2001 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:20 AM.

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