Cron job, compress/tar the backup?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > Cron job, compress/tar the backup?




Pages (2): [1] 2 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Cron job, compress/tar the backup?  
Simon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-18-07 06:21 PM

Not sure if this is a unix shell question or a mysql one.

I run the following cron job every nights at midnight, (one job per day of
the week).

mysqldump --opt -Q -u username --password=password database >
/home/folder/public_html/backups/mon.sql

But that is upward of 300Mb every night, (and thankfully it is growing).
How can I zip/tar the created file 'mon.sql' and then remove it?

Makes it easier to copy to a third party every so often.

Many thanks

Simon






[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
Cyrus Kriticos


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-18-07 06:21 PM

Simon wrote:
> Not sure if this is a unix shell question or a mysql one.
>
> I run the following cron job every nights at midnight, (one job per day
> of the week).
>
> mysqldump --opt -Q -u username --password=password database >
> /home/folder/public_html/backups/mon.sql
>
> But that is upward of 300Mb every night, (and thankfully it is growing).
> How can I zip/tar the created file 'mon.sql' and then remove it?

mysqldump --opt -Q -u username --password=password database | gzip -9 >
/home/folder/public_html/backups/mon.sql.gz

--
Best     |  "Was bekommt man/frau, wenn man/frau Software kauft?
regards  |  Nichts außer einem Haufen Nullen und Einsen."
Cyrus    |  -- aus d. Lizenzvereinbarung von Spybot Search&Destroy





[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
Gretch


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-18-07 06:21 PM

In news:5iocsaF3p9oiqU1@mid.individual.net,
Simon <spambucket@example.com> wrote:

> mysqldump --opt -Q -u username --password=password database >
> /home/folder/public_html/backups/mon.sql
>
> But that is upward of 300Mb every night, (and thankfully it is
> growing). How can I zip/tar the created file 'mon.sql' and then
> remove it?

Just don't create it to start with:
mysqldump --opt -Q \
-u username --password=password database | \
tar czf /home/folder/public_html/backups/mon.sql.tgz -







[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
Neil Cherry


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-19-07 12:20 AM

On Sat, 18 Aug 2007 08:54:32 -0700, Gretch wrote:
> In news:5iocsaF3p9oiqU1@mid.individual.net,
> Simon <spambucket@example.com> wrote:
> 
>
> Just don't create it to start with:
> mysqldump --opt -Q \
>     -u username --password=password database | \
>     tar czf /home/folder/public_html/backups/mon.sql.tgz -

I don't think this command will work and tar is not the appropriate
command fo compressing a file. Gzip is a better choice. The previous
message gave a good example.

--
Linux Home Automation         Neil Cherry       ncherry@linuxha.com
http://www.linuxha.com/                         Main site
http://linuxha.blogspot.com/                    My HA Blog
Author of:    	Linux Smart Homes For Dummies





[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
blazej


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-19-07 06:22 PM

Neil Cherry wrote:
> On Sat, 18 Aug 2007 08:54:32 -0700, Gretch wrote: 
>
> I don't think this command will work and tar is not the appropriate
> command fo compressing a file. Gzip is a better choice. The previous
> message gave a good example.
>
This command should work. Here tar was used with (zip/gzip) compression
optin - so will create tgz fie which is compressed tar archive....

Bla





[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
Rob S


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-20-07 12:22 AM

blazej wrote:
> Neil Cherry wrote: 
> This command should work. Here tar was used with (zip/gzip) compression
> optin - so will create tgz fie which is compressed tar archive....
>
You could do it that way if you like, but it's an unnecessary use of
tar, as there is only one filed to be compressed and backed up.

--

Rob
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
http://www.aspir8or.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -


This is Unix and Netware country, on a quiet night you can hear NT Reboot.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -





[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
blazej


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-20-07 12:22 AM

Rob S wrote:

> You could do it that way if you like, but it's an unnecessary use of
> tar, as there is only one filed to be compressed and backed up.
>
Yeah - that's right - tar  step is not needed and really gzip is enough.





[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
Neil Cherry


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-20-07 12:22 AM

On Sun, 19 Aug 2007 17:36:24 +0100, blazej wrote:
> Neil Cherry wrote: 
> This command should work. Here tar was used with (zip/gzip) compression
> optin - so will create tgz fie which is compressed tar archive....

Sorry to keep on this (I guess I've hijacked the thread, my
apologies), I'm really curious to see if it's something I don't know
rather than wrong/right. Here's what I get in my home directory:

$ ls bashrc
bashrc

$ cat bashrc | tar czf mon.sql.tgz -
tar: -: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors

$ type tar
tar is /bin/tar

I always thought that tar was looking for file names to create the tar
file. Maybe I misunderstand the mysqldump command?

--
Linux Home Automation         Neil Cherry       ncherry@linuxha.com
http://www.linuxha.com/                         Main site
http://linuxha.blogspot.com/                    My HA Blog
Author of:    	Linux Smart Homes For Dummies





[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
Gretch


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-20-07 12:22 AM

In news:slrnfchfi2.5fl.njc@cookie.uucp,
Neil Cherry <njc@cookie.uucp> wrote:

> I always thought that tar was looking for file names to create the tar
> file. Maybe I misunderstand the mysqldump command?

No, it was my mistake; you are correct.





[ Post a follow-up to this message ]



    Re: Cron job, compress/tar the backup?  
Neil Cherry


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-20-07 12:22 AM

On Sun, 19 Aug 2007 16:33:33 -0700, Gretch wrote:
> In news:slrnfchfi2.5fl.njc@cookie.uucp,
> Neil Cherry <njc@cookie.uucp> wrote:
> 
>
> No, it was my mistake; you are correct.

Thanks, it makes me feel better as I've been a little dain bread for
the last few weeks. It got so bad that I'd confuse the concept of yes
and no (I'm dyslexic).

--
Linux Home Automation         Neil Cherry       ncherry@linuxha.com
http://www.linuxha.com/                         Main site
http://linuxha.blogspot.com/                    My HA Blog
Author of:    	Linux Smart Homes For Dummies





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:05 AM.      Post New Thread    Post A Reply      
Pages (2): [1] 2 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register