Unix Shell - Cron job, compress/tar the backup?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > August 2007 > Cron job, compress/tar the backup?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Cron job, compress/tar the backup?
Simon

2007-08-18, 1: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

Cyrus Kriticos

2007-08-18, 1: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
Gretch

2007-08-18, 1: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 -


Neil Cherry

2007-08-18, 7:20 pm

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
blazej

2007-08-19, 1: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
Rob S

2007-08-19, 7:22 pm

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.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
blazej

2007-08-19, 7:22 pm

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.
Neil Cherry

2007-08-19, 7:22 pm

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
Gretch

2007-08-19, 7:22 pm

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.
Neil Cherry

2007-08-19, 7:22 pm

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
Simon

2007-08-21, 7:24 pm

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


Many thanks it works great.
Now if only I could remember the command to unzip it and restore the db...

Simon

Bill Marcum

2007-08-22, 1:22 am

On Tue, 21 Aug 2007 20:45:25 +0200, Simon
<spambucket@example.com> wrote:
>
>
>
> Many thanks it works great.
> Now if only I could remember the command to unzip it and restore the db...
>
> Simon
>

The opposite of gzip is gunzip. Unfortunately I'm not familiar with
mysql commands.


--
I don't mind arguing with myself. It's when I lose that it bothers me.
-- Richard Powers
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com