LinuxQuestions.org
Review your favorite Linux distribution.
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 03-07-2012, 05:32 AM   #1
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Rep: Reputation: 16
Question After backup can't find directory to .gz on Centos


When i run this:

I login to ssh and from home directory i was run:

Code:
mysqldump -u root -h localhost -pMYPASSHERE database_name > mydatabase-$(date +%d-%m-%Y).sql; gzip mydatabase-$(date +%d-%m-%Y).sql mydatabase-$(date +%d-%m-%Y).gz
And at the end i got this:

Code:
gzip: mydatabase-07-03-2012.gz: No such file or directory


Any ideas?
 
Old 03-07-2012, 05:35 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
well it doesn't exist does it? You're trying to create it, right? just remove that bit from the gzip command, it'll automatically give the output file that name.
 
Old 03-07-2012, 05:51 AM   #3
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Can you please adjust it for me?

I didn't understant it

This one is creating:

Code:
mysqldump -u root -h localhost -pMYPASSHERE database_name > mydatabase-$(date +%d-%m-%Y).sql;
the file mydatabase-07-03-2012.sql on home directory and after this this one:

Code:
gzip mydatabase-$(date +%d-%m-%Y).sql mydatabase-$(date +%d-%m-%Y).gz
Is compressing the mydatabase-07-03-2012.sql to mydatabase-07-03-2012.gz

or not?

I just need to compress my database .gz for backup and then when i need it to be able to decompress it on the same folder with extension .sql

Last edited by ASTRAPI; 03-07-2012 at 05:53 AM.
 
Old 03-07-2012, 05:52 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
IS what I said really that confusing??

gzip mydatabase-$(date +%d-%m-%Y).sql
 
Old 03-07-2012, 06:19 AM   #5
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
Originally Posted by ASTRAPI View Post
When i run this:
...
Code:
mysqldump -u root -h localhost -pMYPASSHERE database_name > mydatabase-$(date +%d-%m-%Y).sql; gzip mydatabase-$(date +%d-%m-%Y).sql mydatabase-$(date +%d-%m-%Y).gz
...
I do it like this:
Code:
mysqldump -u root -h localhost -pMYPASSHERE database_name > mydatabase-$(date +%d-%m-%Y).sql && gzip mydatabase-$(date +%d-%m-%Y).sql
which is different from yours here at
(date +%d-%m-%Y).sql; gzip
I have &&
Quote:
&& lets you do something based on whether the previous command completed successfully
and I don't have extra mydatabase-$(date +%d-%m-%Y).gz

Last edited by lithos; 03-07-2012 at 06:23 AM.
 
Old 03-07-2012, 06:22 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
I'd do it by piping directly into gzip, not redirecting to a file. Could possibly fill up the disk with that decompressed dump
 
Old 03-07-2012, 06:29 AM   #7
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
Originally Posted by acid_kewpie View Post
I'd do it by piping directly into gzip, not redirecting to a file. Could possibly fill up the disk with that decompressed dump
Of course, stupid of me,
that would be :
Code:
mysqldump -u root -h localhost -pMYPASSHERE database_name | gzip > mydatabase-$(date +%d-%m-%Y).sql.gzip
 
Old 03-07-2012, 06:52 AM   #8
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Ok it works

But is it ok for big databases to compress on the fly?

And one last question please:

How can i extract it on the same folder as .sql ?

Thank you
 
Old 03-07-2012, 06:56 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
you aren't compressing a database, you're compressing wasteful ASCII text. And you're avoiding not only using the disk space in the first place, but the IO costs of writing it all to the disk and then all back off the disk again, which on a big database, can be a big win.

Last edited by acid_kewpie; 03-07-2012 at 06:59 AM.
 
Old 03-07-2012, 07:11 AM   #10
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Is it any better way to compress the database for the backup?
 
Old 03-07-2012, 07:36 AM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
what do you want to be better about it?
 
Old 03-07-2012, 07:55 AM   #12
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Maybe smaller size?
 
Old 03-07-2012, 07:56 AM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
gzip -9
 
Old 03-07-2012, 08:06 AM   #14
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Ok thanks
 
  


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
CENTOS Backup JJJCR Linux - General 3 09-01-2011 10:36 PM
Find directory older than x and mv directory with sub files command ajhart Linux - Newbie 4 07-15-2011 06:24 AM
centos image backup salimshahzad Linux - Server 3 10-24-2010 05:55 AM
CentOS 5.4 Backup Software Needed athomas Linux - Software 6 04-28-2010 09:31 AM
LXer: CentOS Directory Server On CentOS 5.2 LXer Syndicated Linux News 0 08-06-2008 10:20 PM


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