On Thu, Sep 06, 2001 at 10:22:51AM -0400, Jacob Singh wrote:
> I'm just wondering how everyone manages their MySQL backups, I'm
> looking for a better solution than manual. any scripts or example
> would be especially appreciated. tnks
Here is a script I use:
#!/usr/bin/perl
$now = time;
$directory = "/home/user/backups";
# these are the databases I back up
@databases = ("mysql", "accounts", "data");
foreach $database (@databases) {
$backup = "mysqldump \-\-add-drop-table -u user -ppass $database";
$zip = "| gzip > $directory/$database.$now.gz";
system("$backup $zip");
# This stays commented, because I don't want to restore all the time.
# unless($database eq "mysql") {
# $restore = "|mysql -u user -ppass test_$database";
# system("$backup $restore");
# }
}
# This allows me to keep 7 copies of the backups at all times.
# They also get backed up to tape, but this is more convenient for me.
opendir BACKUPS, $directory;
foreach $file (readdir BACKUPS) {
if(-M "$directory/$file" > 6) {
unlink "$directory/$file";
}
}
--
Jason Stechschulte
[EMAIL PROTECTED]
--
Let's say the docs present a simplified view of reality... :-)
-- Larry Wall in <[EMAIL PROTECTED]>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]