Results 1 to 9 of 9

Thread: Backup and Mail MySQL Database using PHP

  1. #1
    Join Date
    Feb 2005
    Location
    India
    Posts
    11,004

    Default Backup and Mail MySQL Database using PHP

    This script will show you how to take complete mysql backup using php and email the backup file as attachment.

    Code:
    < ?php
    $datestamp = date("Y-m-d");      // Current date to append to filename of backup file in format of YYYY-MM-DD
    
    /* CONFIGURE THE FOLLOWING SEVEN VARIABLES TO MATCH YOUR SETUP */
    $dbuser = "";            // Database username
    $dbpwd = "";            // Database password
    $dbname = "";            // Database name. Use --all-databases if you have more than one
    $filename= "backup-$datestamp.sql.gz";   // The name (and optionally path) of the dump file
    $to = "[email protected]";      // Email address to send dump file to
    $from = "[email protected]";      // Email address message will show as coming from.
    $subject = "MySQL Backup File";      // Subject of email
    
    $command = "mysqldump -u $dbuser --password=$dbpwd $dbname | gzip > $filename";
    $result = passthru($command);
    
    $attachmentname = array_pop(explode("/", $filename));   // If a path was included, strip it out for the attachment name
    
    $message = "Compressed database backup file $attachmentname attached.";
    $mime_boundary = "< <<:" . md5(time());
    $data = chunk_split(base64_encode(implode("", file($filename))));
    
    $headers = "From: $from\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: multipart/mixed;\r\n";
    $headers .= " boundary=\"".$mime_boundary."\"\r\n";
    
    $content = "This is a multi-part message in MIME format.\r\n\r\n";
    $content.= "--".$mime_boundary."\r\n";
    $content.= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
    $content.= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $content.= $message."\r\n";
    $content.= "--".$mime_boundary."\r\n";
    $content.= "Content-Disposition: attachment;\r\n";
    $content.= "Content-Type: Application/Octet-Stream; name=\"$attachmentname\"\r\n";
    $content.= "Content-Transfer-Encoding: base64\r\n\r\n";
    $content.= $data."\r\n";
    $content.= "--" . $mime_boundary . "\r\n";
    
    mail($to, $subject, $content, $headers);
    
    unlink($filename);   //delete the backup file from the server
    ?>
    Add this php script in your cronjobs and it will backup the db in some fixed intervals
    VIDEO WORLD : LATEST HOLLYWOOD || BOLLYWOOD || SOUTH INDIAN VIDEOS || TRAILERS

  2. #2
    Join Date
    Jan 2011
    Location
    USA
    Posts
    1

    Default Okay, here's the really cool trick:

    Here's my preferred way: Select the text and click on the Font Family name in the pop-up menu in the Options Bar (it will become highlighted).

  3. #3
    Join Date
    Feb 2011
    Posts
    5

    Default

    thank you for data

  4. #4
    Join Date
    Feb 2011
    Posts
    1

    Default thanks

    Hi, thanks a lot for your great post, it has really lot of worth for me.

    I was looking for a backup solution but they are expensive. I found ESXi which could be interesting.....


    Greets! :D
    Last edited by crownd; 02-12-2011 at 09:58 PM.

  5. #5

    Default

    very helpful post for me...thanks a lot!

  6. #6
    Join Date
    Dec 2017
    Location
    United States
    Posts
    19,962

    Default when viagra and cialis dont work

    However, not all opiate receptors have the same analgesic potency when stimulated does propecia work

  7. #7
    Join Date
    Dec 2017
    Location
    United States
    Posts
    19,962

    Default how much cialis can you take at one time

    buy zithromax without prescription online Differences in estrogen pathway may predict sensitivity or resistance to tamoxifen and its antiestrogenic metabolites in tumor cell and its inhibition by tamoxifen metabolites tumor biology factors

  8. #8
    Join Date
    Dec 2017
    Location
    United States
    Posts
    19,962

    Default free cialis samples

    7 Obesity may elevate risk by 50 in post menopausal women by altering endogenous estrogen production ivermectin pour on

  9. #9
    Join Date
    Dec 2017
    Location
    United States
    Posts
    19,962

    Default cialis vs viagra vs levitra cost

    ivermectin for cats Eye Doctors Give Breast Cancer Patients One Less Thing to Worry About

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •