Category Archives: Perl

Simple MySQL Backup Script

Below is a simple database backup script to use with MySQL.

#!/usr/bin/perl -w

use strict;

# Backup – Script used to backup MySQL databases to an NFS share.
# VERSION: 1.2
# DATE: 12152005
# AUTHOR: packetmad

# This is a Freebsd 4.x-centric script. It may run on other
# versions of Freebsd, or any other BSD for that matter, but I
# wrote it on a Freebsd 4.7 system. It’s not even guaranteed
# to run on that.

Win32 Perl

Actually did my first win32 perl script at work today. What a pita that can be when you are changing from *n?x perl. Most of the problems I encountered were editor issues. Guess I should have just gotten vi for Windows and been done with it.

###
# First we’ll change into the directory passed in the command line
###
$workdirectory = @ARGV[0];
#print (“$workdirectory\n”);
chdir (“$workdirectory”) || die “cannot cd to $workdirectory”;

###
# Lets get a numeric date for use in naming the zip files
###
$insanedate = `date /t`;
# print $insanedate;
$insanedate =~ /.*?(\d{2})\/(\d{2})\/(\d{4})/;
$sanedate = “$1$2$3”;
# print “$sanedate\n”;