The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cron job to backup database and email the attachment

Discussion in 'E-mail Discussions' started by gatzke, Oct 10, 2009.

  1. gatzke

    gatzke Registered

    Joined:
    Oct 10, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi, I'm trying to backup my database and send the attachment to my hotmail account. Everything goes well using the following script, but the file doesn't get attached. Instead, I get a message of completely garbled text and squares. It's like the email was trying to read the bits from the .gz file. Here's the cron command I use:

    mysqldump --user MY_USERNAME -pMY_PASSWORD --databases MY_DATABASE_NAME | gzip -cq9 > /home/MY_USERNAME/database_backup.sql.gz && mail -s "database backup" MY_EMAIL_ADDRESS < /home/MY_USERNAME/database_backup.sql.gz
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hi,

    I want to warn against sending the backup of your database as an email attachment through possibly insecure email.

    It would be far better to have it FTP securely to some location for you rather than emailing the fle, which I don't consider to be a very secure mechanism for transmission of data. Additionally, you could end up with a very large file when the database becomes large and FTP (or SCP) are better methods to transfer large files rather than email.

    If you want to use FTP, you could just use the Backup method that already exists in cPanel's Backup area and call it from a cron.

    Just wanted to provide those points to keep in mind.
     
  3. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    This is very unwise on a great many levels!

    You have opened up quite a few security holes if that really is your cron command and that is before even mentioning your sending your database backup by email which is a whole other Pandora's box of problems itself.
     
  4. gatzke

    gatzke Registered

    Joined:
    Oct 10, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    OK, I think I'll take your word for it - FTP it is. ;)

    Cheers.
     
Loading...

Share This Page