SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2000
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Everynight, I would back up my 2 databases for my website using SSH/Telnet access. My host also offers crontab and I have been looking into this feature, but I have a couple of questions.

    Lets say my username is steven
    password is test
    database name is forums

    If I put in the following command on crontab it should automatically dump my database correct.

    Code:
    mysqldump --opt --user=steven --password=test forums > forums.sql
    I have heard something about crontab e-mailing the user when the command that it's given it is successfull, and I was wondering if someone would be kind enough to elaborate on this feature.

    Finally,
    When I did a dump of one of my databases through SSH/Telnet it was 953KB, but when I did it through Crontab it was 923KB, why the difference?

    Thanks
    Steven
    Have you ever been ripped off, lied to or cheated? If so, check out
    Baddealings.com

  2. #2
    Freelance Web Designer KeithMcL's Avatar
    Join Date
    Oct 1999
    Location
    Dublin, Ireland
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Steven,

    Chris from vBulletin wrote a script that will do it for you, so I wrote an article on backing up MySQL driven forums/databases using this script and setting up the crontab option.

    You can read the article here

    As far as your second question is concerned, I don't know the answer, sorry.

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Crontab will email you the output of the commands it runs on your behalf; however, in your case, the output is being redirected to the .sql backup file. Thus, crontab has nothing to email you.

    I'm not sure why the output sizes would be different. Have you tried comparing the two in a text editor to see if you can spot any obvious differences?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm no expert in shell scripting, but here is what I made and it worked with my site:
    {save as dumbshell}
    Code:
    #!/bin/ksh
    #
    
    if `mysqldump --opt --user=usr --password=pwd db-name>backup.sql`;
    then echo "Good shape"
    else echo "Trouble again!"
    fi
    Then run it with "sh dumbshell"

    Btw, anyone knows how to use "mail"?
    I tried the following but it just wait for me to input the body, how to terminate it?

    mail -s "Subject" email@ad-rotator.com

    Thanks
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mail? as in PHP?

    PHP Code:
    mail("user@mydomain.com""Subject""Body""header info"); 
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  6. #6
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No, mail as in sendmail.

    I've only seen it done in Perl; but you could run the Perl from your shell script...

    Code:
    $mailprog = '/usr/sbin/sendmail';
    
    open (MAIL, "|$mailprog -t") || print "Can't start mail program";
    print MAIL "To: email@domain.com\n";
    print MAIL "From: \"From Name\" \<from@domain.com\>\n";
    print MAIL "Subject: Subject goes here\n\n";                 
    print MAIL "Message text here...";  
    print MAIL "\n\n";
    close (MAIL);
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  7. #7
    SitePoint Zealot
    Join Date
    May 2000
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what I use for my shell script:

    Code:
    #!/bin/sh
    
    mail -s "Weekly Database Backup" mymail@mail.com << [BODY]
    
    Hello,
    
    This is the automatic weekly email from the FOO
    server. Your database has just been backed up. 
    
    [BODY]
    Hope it helps.

  8. #8
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, cool, now I know how to terminate it.
    Btw, what if I don't want anything in the BODY, how would I terminate it?
    It seems that it always needs a new line?
    Could anyone redirect me to the documentation page? I tried man but nothing helpful.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


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
  •