LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2012, 08:05 PM   #1
steak1987
Member
 
Registered: Jan 2012
Posts: 130

Rep: Reputation: Disabled
Tar command line questions (am I missing something?)


Hey all, ive been dabbling in linux (mainly ubuntu,a bit of fedira) for a while, but occasionally hit into a few sangs. This is one of them.


Im currently on a "plop linux" live CD, and im trying to backup my old home folder from my old ubuntu installation using tar.

I had the original parition "/dev/sda1" and I mounted it into a new folder "/mnt/ubuntu". I also mounted the backup partition "dev/sda4" to "/mnt/backup'

Then I cd to the backup directory "/mnt/backup" in terminal, and tried out
Code:
tar -cvpzf backup.tar.gz /mnt/ubuntu/home/[username]/test.directory/
Everything turned out hunkydory, except, when I opened the archive "backup.tar.gz", it started from the "mnt" directory, as opposed to simply the test folder.

My question is : How can I specify tar to "begin" the archive, at a certain point ?
EG, make a tar of a directory inside my user-folder, and the resulting archive opens from there, as opposed to "mnt>ubuntu>home>[username]>specified folder"

Also, if I want to exclude all hidden files in that directory, I assume I need to put
Code:
--exclude .*
after
Code:
tar -cvpzf backup.tar.gz /mnt/ubuntu/home/[username]/test.directory/
?
 
Old 01-14-2012, 08:32 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi steak1987,

As far as I know if you do not want the full directory path then you have to run the command in that directory itself. As follows:

Code:
cd /mnt/ubuntu/home/[username]
and then

Code:
tar -cvpzf backup.tar.gz test.directory/
You can use --exclude .* but it will not be useful as tar anyways going to ignore that for hidden files.
 
Old 01-14-2012, 08:44 PM   #3
steak1987
Member
 
Registered: Jan 2012
Posts: 130

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by T3RM1NVT0R View Post
Hi steak1987,

As far as I know if you do not want the full directory path then you have to run the command in that directory itself. As follows:

Code:
cd /mnt/ubuntu/home/[username]
and then

Code:
tar -cvpzf backup.tar.gz test.directory/
You can use --exclude .* but it will not be useful as tar anyways going to ignore that for hidden files.

so if I cd to
Code:
cd /mnt/ubuntu/home/[username]
how can I modify this command :
Code:
tar -cvpzf backup.tar.gz test.directory/
to create the tar in
Code:
/mnt/backup
, as opposed to inside the user folder ? Also, where is the temporary file during this process ?
 
Old 01-14-2012, 08:46 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Like this:

Code:
tar -cvpzf /mnt/backup/backup.tar.gz test.directory/
 
1 members found this post helpful.
Old 01-14-2012, 08:53 PM   #5
steak1987
Member
 
Registered: Jan 2012
Posts: 130

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by T3RM1NVT0R View Post
Like this:

Code:
tar -cvpzf /mnt/backup/backup.tar.gz test.directory/
Thanks, question resolved.
 
Old 01-14-2012, 08:54 PM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

You're welcome. Enjoy linux!!!
 
  


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
[SOLVED] Command line install issues, regarding missing libs. rohanvr_21 Linux - Software 4 09-27-2010 12:36 PM
Installing an RPM or Tar.GZ package on CDROM in Command Line. mr.linux.noob Linux - General 10 10-28-2008 01:04 AM
USB tar backups fail in cron, not from command line StikShift Linux - General 5 03-10-2008 05:54 PM
How do I install .tar.gz apps via the command line? BigFoot13 Linux - Newbie 33 11-14-2006 03:06 PM
Kdetv command line (missing?) option AliDigitaly Linux - Software 0 09-30-2005 05:11 PM


All times are GMT -5. The time now is 03:54 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration