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

  • Home
  • SEARCH
  • 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

Just wondering how you would go about implementing something similar to stackoverflow'd related questions.
I'm wondering how you would go about designing a good permgen space string in
I was wondering, how would you go about writing an application that basically houses
I've been wondering about how hard it would be to write some Python code
I'm wondering what good ways there would be make assertions about synchronization or something
I'm wondering what would be the best prectice regarding mainataining connections to the database
I was always wondering about this seemingly utopic world of open source. Assuming the
I provide a web service to my organisation. i was wondering would anyone recommeding
I was wondering what would be the best strategy to implement a badges system
As a follow-up to another question , I was wondering what would be the

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.