Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3610166
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:43:05+00:00 2026-05-18T21:43:05+00:00

I was wondering how would I go about using mysqldump to backup my database

  • 0

I was wondering how would I go about using mysqldump to backup my database and send the data to an email address using PHP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:43:06+00:00Added an answer on May 18, 2026 at 9:43 pm

    This require phpmailer:

    <?php
    
       require("class.phpmailer.php");
    
       header("Content-type: text/plain");
    
       // --- MySQL et path --------------------------------------------------------
       $mysql_host     = 'XXXXXXX';
       $mysql_username = 'XXXXXXX';
       $mysql_password = 'XXXXXXX';
       $mysql_db       = 'XXXXXXX';
       $mail_to1        = 'XXXXXXXXXXXXXXXXXXXX';
       $mail_to1_name   = 'XXXXXXXXX';
       $mail_to2        = 'XXXXXXXXXXXXXXXXXXXX';
       $mail_to2_name   = 'XXXXXXXXX';
       // --------------------------------------------------------------------------
    
    
       $fname = '' . $mysql_db . '_' . strftime('%Y%m%d-%H%M%S') . '.sql.gz';
       echo "Backing up to $fname\n";
       system('mysqldump --host=' . $mysql_host . ' --user=' . $mysql_username . 
            ' --password=' . $mysql_password . ' ' . $mysql_db . ' | gzip >' . 
            $fname);
    
       $mail = new PHPMailer();
       $mail->SetLanguage("en", "language/");
       $mail->From = 'XXXXXXXXXXXXXXXXXXXXXX';
       $mail->FromName = 'Webmaster';
       $mail->AddAddress($mail_to1, $mail_to1_name);
       $mail->AddAddress($mail_to2, $mail_to2_name);
       $mail->WordWrap = 50;         // set word wrap to 50 characters
       $mail->IsHTML(false);         // set email format to plain text
       $mail->Subject = '[XXX] Backup MySQL - ' . strftime('%x %X');
       $mail->Body    = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
    
       if (!$mail->AddAttachment($fname)) // add attachments
       {
          echo 'Erreur : ' . $mail->ErrorInfo . "\n";
          $mail->Body .= "\n" . 'Erreur : ' . $mail->ErrorInfo;
       }
    
       if (!$mail->Send())
       {
          echo 'Message could not be sent. <p>';
          echo 'Mailer Error: ' . $mail->ErrorInfo;
          exit;
       }
    
       echo 'Message has been sent';
       unlink($fname);
       exit;
    
    ?>
    

    Used on some BDD (the host only provides some php script jobs, no cron) and mail are sent to gmail. You can add a -9 to gzip or use bzip for better compression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how would go about displaying five images in a row using
I was wondering what you would think about using jsperf.com Chrome test results as
i'm a php novice, and i'm wondering the best way to go about using
I was wondering how I would go about using Python to create a Graph
I'm using Visual Studio C# Express and I'm wondering how I would go about
I was wondering how one would go about using sqlite3 to validate users in
I'm wondering how i would go about making the following application: a user signs
I am wondering how I would go about performing a certain function if a
I was wondering how I would go about mapping 2D screen coordinates to a
I'm wondering how I would go about the addition and subtraction of numbers in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.