Skip to content

Instantly share code, notes, and snippets.

@fgbreel
Created April 20, 2016 14:17
Show Gist options
  • Save fgbreel/408a8fa29805d67ad0e1c7337a89d684 to your computer and use it in GitHub Desktop.
Save fgbreel/408a8fa29805d67ad0e1c7337a89d684 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use DBI;
# Connect to the local database
$dbh = DBI->connect('DBI:mysql:host=localhost;database=mysql', 'root', 'password') || die;
# Flush and lock tables to prepare for LVM snapshot
$dbh->do('FLUSH TABLES WITH READ LOCK;');
# Create LVM snapshot volume
system('lvcreate -L8G -s -n mysqlbackup /dev/vg0/mysql');
# Release table lock
$dbh->do('UNLOCK TABLES;');
# Disconnect from database
$dbh->disconnect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment