Announcement

Collapse
No announcement yet.

Scripts to backup my forum? With linux

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

  • Scripts to backup my forum? With linux

    I have full root access to my machine running CentOS. (Although I would rather run the script as a user then as root) I know how to set up a cron job to backup my database. But what I am looking for is a way to backup my MySQL vB database every 24 hours at 3:01am and labeling it as the date. (vbbackup-day-month-year.sql for example) After a week of that it would delete the previous backup that is older then a week.

    Does anyone know of a script, free or paid? It can be run via shell, cronjob, as a bash script, or anything that will run automatically on a linux machine.
    Running vB since 4-14-2002

  • #2
    vBulletin has a shell backup script. It is in the do_not_upload/ folder.

    Comment


    • #3
      Does the script do what I need? How do I get it to run every 24 hours? Via cron?
      Running vB since 4-14-2002

      Comment


      • #4
        Originally posted by Floris View Post
        vBulletin has a shell backup script. It is in the do_not_upload/ folder.
        Interesting, I never noticed, it's more simple than tipe the whole command with that bunch of parameters.

        How can that command be used with cron, I'm interested. I'll have a look on Google "manual".
        Italian Body Building & Fitness : www.BodyWeb.com
        Italian unofficial support Forum : www.vBulletin.it

        Comment


        • #5
          Crontab syntax :-
          A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

          * * * * * command to be executed
          - - - - -
          | | | | |
          | | | | +----- day of week (0 - 6) (Sunday=0)
          | | | +------- month (1 - 12)
          | | +--------- day of month (1 - 31)
          | +----------- hour (0 - 23)
          +------------- min (0 - 59)

          A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM.

          crontab 30 18 * * * rm /home/someuser/tmp/*


          What we need should be : crontab 0 3 * * * /path/vb_backup.sh
          Italian Body Building & Fitness : www.BodyWeb.com
          Italian unofficial support Forum : www.vBulletin.it

          Comment


          • #6
            This is the script I use :

            #! /bin/bash

            # Automated database datestamp backup



            mysqldump --opt -C -u *USERNAMEHERE* -p*PASSWORD* *DBNAME* | gzip > /home/userdir/backups/`date +\%d\%m\%y`.gz
            Also has the advantage of compressing your DB at the same time. Just setup Cron to run it when ever you want.

            Comment


            • #7
              Thats more or less what the script vBulletin includes does but it also parses your vBulletin config file to get the various bits of information.
              Scott MacVicar

              My Blog | Twitter

              Comment


              • #8
                If I'm on the same server I use mysqlhotcopy, do you think it's better or rather the same? (3 Giga)
                Usually I dump the DB from another server, and I'm pretty much forced to use the mysqldump manual command.
                Italian Body Building & Fitness : www.BodyWeb.com
                Italian unofficial support Forum : www.vBulletin.it

                Comment


                • #9
                  Man issue I have, is will it delete the old files?
                  Running vB since 4-14-2002

                  Comment


                  • #10
                    Originally posted by IDN View Post
                    Man issue I have, is will it delete the old files?
                    Probably not, let's do it.
                    Italian Body Building & Fitness : www.BodyWeb.com
                    Italian unofficial support Forum : www.vBulletin.it

                    Comment


                    • #11
                      Maybe something like this works in a bash.sh script which you can put in your cron.

                      find /yourdir/backups -mtime +5 -exec rm {} \; // 5 is 5 days old

                      Comment


                      • #12
                        Done

                        We could just add the vbulletin version in the vb_backup.sh script since sometime we need to match web forum files backups with mysql backups.
                        Italian Body Building & Fitness : www.BodyWeb.com
                        Italian unofficial support Forum : www.vBulletin.it

                        Comment


                        • #13
                          What exactly does the backup scrip included do?

                          Looking at it, it will do dbname-date.sql? So, it would create unlimited copies technically. So all I need to do is figure out how to remove the files automatically?
                          Running vB since 4-14-2002

                          Comment


                          • #14
                            You might add a second cron script to do that or modify the current one to remove the oldest copy after the backup has been run.
                            Scott MacVicar

                            My Blog | Twitter

                            Comment


                            • #15
                              Originally posted by Sergio68 View Post
                              If I'm on the same server I use mysqlhotcopy, do you think it's better or rather the same? (3 Giga)
                              Usually I dump the DB from another server, and I'm pretty much forced to use the mysqldump manual command.
                              I used to use mysqlhotcopy all the time, it's great in theory and works well if you have slow disks, but pray you never have to restore. I always had to repair my tables which took a not so insignificant amount of time.

                              Then we switched to SCSI disks and the only reason I left mysqldump in the first place (backup/restore speed) was no longer a factor. Oh and plain text seems to compress better too.
                              TheologyWeb. We debate theology. srsly.

                              Comment

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