LinuxQuestions.org
Register a domain and help support LQ
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 02-04-2010, 04:04 PM   #1
pe_
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Rep: Reputation: 0
Add mysqldump to exisiting archive.tgz


Hi im very new to linux,

Is it possible to compress the mysqldump output into say db_backup.sql.tgz. Then add that to an existing archive e.g. backup.tgz in one command or on the fly to save space and deleting it?

Thanks
 
Old 02-04-2010, 04:35 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
A few things:

1) There is no reason to tar a single file, just zip it.

gzip db_backup.sql (which will yield db_backup.sql.gz)

2) There is no good way with a single command to add a file to a tgz/tarball. There are command lines that perform this action in a single command line, but that really isn't what you were asking for.

3) You're not stuck using tar/gzip (bzip2 generally gives better compression for example), you can zip, arj, arc, rar, etc in linux and each has different feature sets you can invoked for the task at hand and several those include adding files to an archive and better compression ratios and common availability on other platforms if you're looking for that.

Tar is a pretty old program that has long been used to store many files in a single file, but that wasn't its original purpose and sometimes it lacks features that reflect that. I do know there is a patch to allow you to add files to a tarball, but I've not used it.
 
Old 02-04-2010, 05:08 PM   #3
pe_
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for the information.

Yes I agree no need to tar the mysqldump thanks for pointing this out. Im using gzip because the files are over 3 Gig and saves on cpu and memory...so i have heard.

Could you gzip the mysqldump + files_backup.tgz to make a new gzip file in one command...e.g.

backup.gz contains:

files_backup.tar.gz <--- already exists
db_backup.gz or db_backup.sql

So to go over it again because im confusing myself

files_backup.tgz has already been made before I run mysqldump so dont need to create it.

Then from the mysqldump command gzip the sql file e.g. db_backup.gz or not. Then gzip both files sql & files_backup.tgz...???

Thanks again
 
Old 02-04-2010, 05:37 PM   #4
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
Here... lets do it this way, operation order:

generate: database.sql
generate: file_backup.tgz
execute: tar cfvz new_backup.tgz database.sql file_backup.tgz

which will yield new_backup.tgz which contains two files database.sql and file_backup.tgz both of which will be compressed and realistically speaking if file_backup.tgz was only file_backup.tar it would probably be just as good because you wouldn't end up double compressing (thus saving a lot of cpu time.)

If you wanted you could gzip the database.sql
If you wanted to you could NOT gzip the file_backup.tgz (tar cfv (or whatever options except z or j)) and you'd still end up with a compressed tar'd archive once you made the new tarball.

You could also look at updating an existing tarball with incrementals... but that's a whole other beast.

Last edited by rweaver; 02-04-2010 at 05:40 PM.
 
  


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
Piping tar bzcat to add a file to a tar.bz2 archive DaveQB Linux - Software 0 06-02-2008 09:28 PM
Script to Add files to a Zip archive with out unzipping it !! prashix Programming 12 10-23-2007 10:19 AM
how do i add a folder into a rar archive steve51184 Linux - Software 6 12-06-2006 05:27 PM
shell script - add file to archive ? xconspirisist Linux - Software 2 03-20-2004 04:27 PM
X Sever crash after xset.tgz & vg16.tgz install lachlan Slackware 0 08-13-2003 03:48 AM


All times are GMT -5. The time now is 12:41 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