Re: Backups, best practices

From: Date: Thu, 06 Sep 2001 15:02:25 +0000
Subject: Re: Backups, best practices
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-12223@lists.php.net to get a copy of this message
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 jpstech@unoh.edu -- Let's say the docs present a simplified view of reality... :-) -- Larry Wall in <6940@jpl-devvax.JPL.NASA.GOV>

« previous php.db (#12223) next »