Announcement

Collapse
No announcement yet.

cron jobs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • cron jobs

    Anyone feel like explaining to me how I can backup my mysql database every night using cron jobs? I am using Cpanel 5.0 on my site. It would be good if I could make it so it does an automatic mysqdump every day or even every 12 hours (since I have the resources). Could someone help me out with this or point me to a good tutorial?

    Thanks,
    Adam
    -
    Visit the Web Scripts Directory @ http://www.scriptz.com
    -
    PHP, CGI, Perl, ASP, JavaScript, CFML, Python and more!

    -

  • #2
    Just click on Cron Jobs and enter the time and command. This example will perfrorm a backup every day at 12:01am:

    Code:
    Minute &nbsp &nbsp Hour&nbsp &nbsp  Day &nbsp &nbsp Month &nbsp &nbspWeekday &nbsp &nbspCommand 
    1          0        *       *           *        mysqldump --opt-u USERNAME -P PASSWORD DATABASE > /path/to/backup.sql
    Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
    Change CKEditor Colors to Match Style (for 4.1.4 and above)

    Steve Machol Photography


    Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


    Comment


    • #3
      So by adding that, it will overwrite the exisiting database from the previous day?
      -
      Visit the Web Scripts Directory @ http://www.scriptz.com
      -
      PHP, CGI, Perl, ASP, JavaScript, CFML, Python and more!

      -

      Comment


      • #4
        Yes. I have three cron backups - two a day (every twelve hours) and another one once per week.

        P.S. You could also append to your command and copy the old backup to another file prior rto making a new backup:

        Code:
        cp -f /path/to/backup.sql backup1.sql; mysqldump --opt -u USERNAME -p PASSWORD DATABASE > /path/to/backup.sql
        Last edited by Steve Machol; Mon 7 Oct '02, 10:23pm.
        Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
        Change CKEditor Colors to Match Style (for 4.1.4 and above)

        Steve Machol Photography


        Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


        Comment


        • #5
          Also, are cron jobs a good way to make backups... same as telnet? I noticed that it was mentioned somewhere that you should close your forums while doing backups...
          -
          Visit the Web Scripts Directory @ http://www.scriptz.com
          -
          PHP, CGI, Perl, ASP, JavaScript, CFML, Python and more!

          -

          Comment


          • #6
            Yes, this is equivalent to making your backups via telnet since both of these processes are run at the command line.

            Since mysqldump locks each table prior to writing it, there's very little chance on something going wrong. However Chris Schrieber posted a script that automates this process and closes the forums during the backup procedure. You'll need to search for this. I think it's a sticky thread in one of the forums.

            Note that my way does have a slight risk since it puts the password on the command line. Thus if you are on a shared server it is *possible* for someone to learn your db info. Just thought I'd make this clear first.
            Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
            Change CKEditor Colors to Match Style (for 4.1.4 and above)

            Steve Machol Photography


            Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


            Comment


            • #7
              I don't have a control panel like Cpanel, all I have is my shell. How do I set up a daily cron job using that?

              Comment


              • #8
                I tried to explain it here: http://www.vbulletin.com/forum/showt...threadid=56368
                this is my sig

                Comment


                • #9
                  Originally posted by Steve Machol
                  Note that my way does have a slight risk since it puts the password on the command line. Thus if you are on a shared server it is *possible* for someone to learn your db info. Just thought I'd make this clear first.
                  Well, I was just about to try it, until I noticed this. I am on a shared server and I wouldn't want to risk someone else getting my entire database (which would include all my users information and e-mail addresses). You mention "my way does have a slight risk"... so what are the other ways that don't have risk? I'd definately like to get this cron job thing working.

                  Thanks,
                  SkuZZy
                  -
                  Visit the Web Scripts Directory @ http://www.scriptz.com
                  -
                  PHP, CGI, Perl, ASP, JavaScript, CFML, Python and more!

                  -

                  Comment


                  • #10
                    Originally posted by Pogo
                    I tried to explain it here: http://www.vbulletin.com/forum/showt...threadid=56368
                    You explained well, but seems too tough for me.
                    -
                    Visit the Web Scripts Directory @ http://www.scriptz.com
                    -
                    PHP, CGI, Perl, ASP, JavaScript, CFML, Python and more!

                    -

                    Comment


                    • #11
                      That works, thanks a bunch, pogo

                      Comment


                      • #12
                        Originally posted by SkuZZy
                        You mention "my way does have a slight risk"... so what are the other ways that don't have risk?
                        I already told you what it was. Here's the link:

                        http://www.vbulletin.com/forum/showt...&threadid=4256
                        Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
                        Change CKEditor Colors to Match Style (for 4.1.4 and above)

                        Steve Machol Photography


                        Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


                        Comment


                        • #13
                          This cron job seems to work perfectly, but for the 5 minutes it's running my users get: "Warning: Too many connections in /forums/admin/db_mysql.php on line 40." ... Anyway around that, even if just to display a more useful message without sending me a ton of emails?

                          Comment

                          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                          Working...
                          X