Nov
20
2009
0

Perl: Simple MySQL Backup Script

#!/usr/bin/perl -w
#
# Quick and dirty dump and time-stamp of listed MySQL databases.
#
# by Timothy M. Kunau
# Note: There will be a point at which this will run out of diskspace for backs
#       and this script has no way of knowing. There is a companion script 
#       (find one-liner) that iterates through the ARCHIVES and erases files over 
#       a certain number of days old.
#       Assumes 'gzip' and 'mysqldump' are in the PATH.
#
#       Admittedly a bit fast and loose with variables and system returns. 
#       It might also be more useful if you could simply pass in the database name
#       as a variable.
#       These, and numerous other improvements, are left as an exercise for the reader.
 
my $workingdir = "/tmp";
my $host       = "localhost";
my $username   = "root";
my $pw         = "THE_ROOT_PASSWORD_FOR_YOUR_MYSQL_INSTANCE_GOES_HERE";
#
# Add a database you want to backup by name to the @dbs array below:
my @dbs        = qw{ hapmap_human concrete gallery2 wordpress };
 
###############  Nothing should need to change beyond this point.
 
# Create a $TIMESTAMP for log entry.
sub get_date {
   # brute force method
 
   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
   if ($year < 10) { $year = "0$year"; }
   $year = $year + 1900;
   if ($mday < 10) { $mday = "0$mday"; }
   if ($hour < 10) { $hour = "0$hour"; }
   if ($min < 10) { $min = "0$min"; }
   if ($sec < 10) { $sec = "0$sec"; }
 
   # Format a $TIMESTAMP for easy sorting
   $monthord = $mon + 1;
   if ($monthord < 10) { $monthord = "0$monthord"; }
   $TIMESTAMP = "$year$monthord$mday$hour$min$sec";
}
 
####
 
# generate TIMESTAMP
&get_date;
 
foreach $db (@dbs) {
 
    # dump databse
    system("mysqldump --flush-logs --opt --host=$host --user=$username --password=$pw $db > $workingdir/$db-$TIMESTAMP.dmp");
 
    # compress dump file to save space
    system("gzip $workingdir/$db-$TIMESTAMP.dmp");
 
}
 
exit;

A simple place to begin, if you are looking for a script to backup your chosen MySQL databases. The code was written years ago and has been in production ever since. I haven’t had the chance or need to change it.

Suggestions for improvement are listed in the code. Please post your solutions in the comments.

Written by kunau in: databases,tools
Nov
04
2009
0

Claude Lelouch’s classic short C’ÉTAIT UN RENDEZ-VOUS available over Vimeo, pulled, and then popped up on sevenload

French filmmaker Claude Lelouch mounted a gyro-stabilized camera to the bumper of a Ferrari 275 GTB and had a professional Formula 1 racer, speed through the heart of Paris.

Though the route and film was carefully planned, Lelouch was unable to obtain a permit. Everything you see is filmed live on the streets on an early August morning in 1976. Speeds reach nearly 140 miles per hour. Lelouch was arrested at the first public showing of the film. The film has become an underground classic.

The unbelievable roar of a classic Ferrari produced by Scaglietti and the squeal of protesting tires, the lack of dialogue, stirs the soul.

UPDATE: The video was pulled from Vimeo shortly after I posted my entry. Likely a copyright issue, this doesn’t diminish the brilliance of the film.

(See also: sevenload: C’ÉTAIT UN RENDEZ-VOUS – short film by Claude Lelouch)
(See also: C’ÉTAIT UN RENDEZ-VOUS – short film by Claude Lelouch (removed))
(See also: Amazon: Rendezvous (1983))
(See also: YouTube: Rendez-vous Making of)
(See also: Wikipedia: Ferrari 275)
(See also: Wikipedia: Claude Lelouch)

Written by kunau in: visualization

Powered by WordPress. 14 queries in 3.090 seconds.