Sponsored Content
Top Forums UNIX for Advanced & Expert Users MYSQL command to take a backup of the database in Redhat linux 7.2 Post 46652 by photon on Wednesday 21st of January 2004 01:16:28 PM
Old 01-21-2004
Here is a way to email a backup using bash, perl, and crontab.

mysqlbackup

Code:
#!/bin/sh 
mysqldump -uroot -ppwd --opt db1 > /sqldata/db1.sql 
mysqldump -uroot -ppwd --opt db2 > /sqldata/db2.sql 
cd /sqldata/ 
tar -zcvf sqldata.tgz *.sql 
cd /scripts/ 
perl emailsql.cgi

Use perl to send a MIME email.

emailsql.cgi

Code:
#!/usr/bin/perl -w 
use MIME::Lite; 
$msg = MIME::Lite->new( 
From => 'mysqlbackup@yoursite.com', 
To => 'you@yoursite.com', 
Subject => 'sqldata.tgz MySQL backup!', 
Type => 'text/plain', 
Data => "Hi You,\n MySQL database backups.");
 
$msg->attach(Type=>'application/x-tar', 
Path =>"/sqldata/sqldata.tgz", 
Filename =>"sqldata.tgz"); 

$msg->send;

Use crontab -e to edit your schedule to run at 2 am every day.

0 2 * * * * /myscripts/mysqlbackup
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mysql in redhat

Does anyone know how to get mysql up and running with the installed version that comes with redhat linux? I've spent hours with no progress. Thank you (13 Replies)
Discussion started by: gparsons70
13 Replies

2. UNIX for Dummies Questions & Answers

command(s) to find size of mysql database?

hello, i'm trying to figure out the size of a mysql database shelling into my server with putty / command line. is there / are there any commands that will return the size of a database, in MB? thanks. (4 Replies)
Discussion started by: sbourgeois
4 Replies

3. UNIX for Dummies Questions & Answers

Redhat linux command to check Version

Hi All, I need to know RedHat linux version installed on a different servers. I know uname -a or /proc/version Is any other command to know the Linux version???? When we telnet to any of the Linux server, the version shows very clearly like Red Hat Enterprise Linux ES release 3 (Taroon... (1 Reply)
Discussion started by: bache_gowda
1 Replies

4. Linux

Linux System Backup Command

Hi All, Is there any command to take complete system backup (image) in Linux like mksysb command in AIX ? Regards (1 Reply)
Discussion started by: m_raheelahmed
1 Replies

5. Shell Programming and Scripting

How to backup a particular Database in MYSQL?

Hi All, Thanks in Advance!! How to backup a particular Databases..through Bash script!! For example i have 6 databases; Anish linux Software Questions Rhce Google these are the databases i have from that i want to take "Anish" and "questions" database backup regularly.... (4 Replies)
Discussion started by: anishkumarv
4 Replies

6. Shell Programming and Scripting

Linux backup command line or live cd?, what do you use?

Linux backup command line or live CD?, what do you use? (4 Replies)
Discussion started by: kaja
4 Replies

7. Shell Programming and Scripting

Increase command length for ksh shell on Redhat Linux

I have a ksh shell script and i need to pass arguments which are generated by data pulled from a database. When the argument to the shell script is too long (about 4000 charecters) the below is the issue observed. I copy the command which is 4000 charecters long from the logs and paste it... (7 Replies)
Discussion started by: mohtashims
7 Replies
CGI::Session::Driver::mysql(3pm)			User Contributed Perl Documentation			  CGI::Session::Driver::mysql(3pm)

NAME
CGI::Session::Driver::mysql - CGI::Session driver for MySQL database SYNOPSIS
$s = CGI::Session->new( 'driver:mysql', $sid); $s = CGI::Session->new( 'driver:mysql', $sid, { DataSource => 'dbi:mysql:test', User => 'sherzodr', Password => 'hello' }); $s = CGI::Session->new( 'driver:mysql', $sid, { Handle => $dbh } ); DESCRIPTION
mysql stores session records in a MySQL table. For details see CGI::Session::Driver::DBI, its parent class. It's especially important for the MySQL driver that the session ID column be defined as a primary key, or at least "unique", like this: CREATE TABLE sessions ( id CHAR(32) NOT NULL PRIMARY KEY, a_session TEXT NOT NULL ); To use different column names, change the 'create table' statement, and then simply do this: $s = CGI::Session->new('driver:mysql', undef, { TableName=>'session', IdColName=>'my_id', DataColName=>'my_data', DataSource=>'dbi:mysql:project', }); or $s = CGI::Session->new('driver:mysql', undef, { TableName=>'session', IdColName=>'my_id', DataColName=>'my_data', Handle=>$dbh, }); DRIVER ARGUMENTS mysql driver supports all the arguments documented in CGI::Session::Driver::DBI. In addition, DataSource argument can optionally leave leading "dbi:mysql:" string out: $s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'shopping_cart'}); # is the same as: $s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'dbi:mysql:shopping_cart'}); BACKWARDS COMPATIBILITY As of V 4.30, the global variable $CGI::Session::MySQL::TABLE_NAME cannot be used to set the session table's name. This is due to changes in CGI::Session::Driver's new() method, which now allows the table's name to be changed (as well as allowing both the 'id' column name and the 'a_session' column name to be changed). See the documentation for CGI::Session::Driver::DBI for details. In particular, the new syntax for "new()" applies to all database drivers, whereas the old - and bad - global variable method only applied to MySQL. Alternately, call $session -> table_name('new_name') just after creating the session object if you wish to change the session table's name. LICENSING
For support and licensing see CGI::Session. perl v5.12.4 2011-07-08 CGI::Session::Driver::mysql(3pm)
All times are GMT -4. The time now is 04:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy