LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-12-2005, 10:40 PM   #1
slack66
Member
 
Registered: Jul 2003
Location: manila
Distribution: slackware 8 to 9
Posts: 199

Rep: Reputation: 30
tar questions???


hi!
i want to backup some of my files in my directory /etc using tar
ex.
tar cvfz mybkup.tgz /etc/passwd /etc/shadow /etc/group /etc/host

is there a way to shorten the /etc/.....to /etc(passwd shadow group host)
or can i create a file that tar will read it what files that i want to archive?

thks in advances!
 
Old 11-12-2005, 11:11 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Yes, you can read the names you want to back up from
a file, look at the -T option.

Please note that the order of parameters in tar is usually
significant, use "tar cvzf "


Cheers,
Tink
 
Old 11-13-2005, 08:12 AM   #3
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 420

Rep: Reputation: 90
Quote:
is there a way to shorten the /etc/.....to /etc(passwd shadow group host)
or can i create a file that tar will read it what files that i want to archive?
You can say
Code:
/etc/{passwd,shadow,group,host}
If you want to learn more about {},[] expansion (and many other things too) read the BASH manual by running "man bash"

Quote:
Please note that the order of parameters in tar is usually
significant, use "tar cvzf "
If i am not wrong the GNU tar version doesn't care about the order of the parameters (or it is the linux version of getopt doing)

I know what the manpage says
Quote:
The first argument to tar must be one of the options: Acdrtux, followed by any optional functions.
The final arguments to tar are the names of the files or directories which should be archived.
but the order doesn't matter. I tested it just to be sure and cvzf,fczv,whatever works the same

(I don't mean any offense. We both try to help. I just mentioned it because it works with any order)
 
Old 11-14-2005, 04:29 AM   #4
slack66
Member
 
Registered: Jul 2003
Location: manila
Distribution: slackware 8 to 9
Posts: 199

Original Poster
Rep: Reputation: 30
thks! can you give me a sample tinkster?
 
Old 11-14-2005, 02:28 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Code:
$> cat ~/back_those_up
/etc/passwd
/etc/shadow
/etc/hosts
$> tar czf ~/etc.tar.gz -T ~/back_those_up
$>  tar tzf etc.tar.gz 
etc/passwd
etc/shadow
etc/hosts

Cheers,
Tink
 
  


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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
tar/restore questions solex Linux - General 5 09-01-2004 02:03 PM
questions between rpm and tar.gz iamthewind Linux - Software 6 12-15-2003 05:08 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM


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