Re: how do I compress large files? was Re: can this backup script work?
- From: Lawrence Krubner <lawrence@xxxxxxxxxxx>
- Date: Fri, 08 Aug 2008 17:46:44 -0400
Lawrence Krubner wrote:
Lawrence Krubner wrote:
Being sane, rational people, we of course want to create a backup of our database everyday. Since the mysqldump produces a file that is over a gig in size, we want to compress the file. I'm worried that I may have just written the worst backup script ever. I glanced at www.php.net and saw that I could use gzcompress() for compression. However, the function takes a string as an argument. So I'm using file_get_contents to load the backup database info as a string.
Is PHP actually using a gig of memory to hold this giant string?
Is there a smarter way to do this?
Cron script, called once a day:
#!/usr/bin/php
<?php
$date = date("Y F d H i s");
$date = str_replace(" ", "_", $date);
$filename = "alb_" . $date . ".sql";
$filepath = "/mnt/krypton_data_backup/$filename";
echo system("mysqldump -uxxxxx -pxxxxx alb > $filepath");
$dataAsString = file_get_contents($filepath);
$compressed = gzcompress($dataAsString);
file_put_contents($filepath, $compressed);
?>
The path is "/mnt/krypton_data_backup/" because it is actually being saved to another server, linked to the current server using NFS.
okay this solved problems with the memory:
system("gzip $filepath");
But now chmod won't work. Is this because the PHP is saving the file to another server? Perhaps PHP doesn't have permission to chmod on another server, even if that server has a directory mounted via NFS? I only gave read/write permissions, on the NFS export, perhaps I can could fix the problem by changing this?
The next problem I face is being able to delete older backups. For that, I'd like to chmod the backups 0777, so PHP will be able to delete the files later on.
.
- References:
- can this backup script work?
- From: Lawrence Krubner
- how do I compress large files? was Re: can this backup script work?
- From: Lawrence Krubner
- can this backup script work?
- Prev by Date: Re: how do I compress large files? was Re: can this backup script work?
- Next by Date: Re: can this backup script work?
- Previous by thread: Re: how do I compress large files? was Re: can this backup script work?
- Next by thread: Re: can this backup script work?
- Index(es):
Relevant Pages
|