MySQL automatic backup script I can run??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Juicy D. Links
    So Fucking Banned
    • Apr 2001
    • 122992

    #1

    MySQL automatic backup script I can run??

    Anybody have a good one i can execute via the shell and also option to run daily via cron?











    Ice is gay
  • bns666
    Confirmed Fetishist
    • Mar 2005
    • 11554

    #2
    bump i need this tooooooooooo.
    CAM SODASTRIPCHAT
    CHATURBATEX LOVE CAM

    Comment

    • psili
      Confirmed User
      • Apr 2003
      • 5526

      #3
      Not sure about InnoDB tables, but can't you put the following in a shell script:

      mysqldump --user=[user] --pass=[pass] --opt [database] > /path/to/backup.sql
      Your post count means nothing.

      Comment

      • Juicy D. Links
        So Fucking Banned
        • Apr 2001
        • 122992

        #4
        Originally posted by bns666
        bump i need this tooooooooooo.
        i am googling now , se if i can find something

        Comment

        • Juicy D. Links
          So Fucking Banned
          • Apr 2001
          • 122992

          #5
          Originally posted by psili
          Not sure about InnoDB tables, but can't you put the following in a shell script:

          mysqldump --user=[user] --pass=[pass] --opt [database] > /path/to/backup.sql
          hmm that looks ripe. i try it

          Comment

          • the alchemist
            Confirmed User
            • Dec 2004
            • 3271

            #6
            To back-up all db's:

            mysqldump --all-databases > all_databases.sql
            264 349 400

            Comment

            • directfiesta
              Too lazy to set a custom title
              • Oct 2002
              • 30135

              #7
              http://www.debianhelp.co.uk/mysqlscript.htm
              I know that Asspimple is stoopid ... As he says, it is a FACT !

              But I can't figure out how he can breathe or type , at the same time ....

              Comment

              • Juicy D. Links
                So Fucking Banned
                • Apr 2001
                • 122992

                #8
                niceeeeeeeeeeeee

                Comment

                • SuckOnThis
                  So Fucking Banned
                  • Oct 2003
                  • 6844

                  #9
                  Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.



                  #!/bin/sh

                  # List all of the MySQL databases that you want to backup in here,
                  # each seperated by a space
                  databases="name of database"
                  # Directory where you want the backup files to be placed
                  backupdir=/path/to/directory

                  # MySQL dump command, use the full path name here
                  mysqldumpcmd=/usr/bin/mysqldump

                  # MySQL Username and password
                  userpassword=" --user=username --password=your password"

                  # MySQL dump options
                  dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"

                  # Unix Commands
                  gzip=/bin/gzip
                  uuencode=/usr/bin/uuencode
                  mail=/usr/sbin/sendmail

                  # Send Backup? Would you like the backup emailed to you?
                  # Set to "y" if you do
                  sendbackup="n"
                  subject="Your MySQL Backup"
                  mailto="[email protected]"

                  # Create our backup directory if not already there
                  mkdir -p ${backupdir}
                  if [ ! -d ${backupdir} ]
                  then
                  echo "Not a directory: ${backupdir}"
                  exit 1
                  fi

                  # Dump all of our databases
                  echo "Dumping MySQL Database"
                  for database in $databases
                  do
                  $mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${database}.dump
                  done

                  # Compress all of our backup files
                  echo "Compressing Dump File"
                  for database in $databases
                  do
                  rm -f ${backupdir}/${database}.dump.gz
                  $gzip ${backupdir}/${database}.dump
                  done

                  # Send the backups via email
                  if [ $sendbackup = "y" ]
                  then
                  for database in $databases
                  do
                  $uuencode ${backupdir}/${database}.dump.gz > ${backupdir}/${database}.dump.gz.uu
                  $mail -s "$subject : $database" $mailto < ${backupdir}/${database}.dump.gz.uu
                  done
                  fi


                  # And we're done
                  ls -l ${backupdir}
                  echo "Dump Successful and Complete!"
                  exit

                  Comment

                  • Juicy D. Links
                    So Fucking Banned
                    • Apr 2001
                    • 122992

                    #10
                    Originally posted by SuckOnThis
                    Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.



                    #!/bin/sh

                    # List all of the MySQL databases that you want to backup in here,
                    # each seperated by a space
                    databases="name of database"
                    # Directory where you want the backup files to be placed
                    backupdir=/path/to/directory

                    # MySQL dump command, use the full path name here
                    mysqldumpcmd=/usr/bin/mysqldump

                    # MySQL Username and password
                    userpassword=" --user=username --password=your password"

                    # MySQL dump options
                    dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"

                    # Unix Commands
                    gzip=/bin/gzip
                    uuencode=/usr/bin/uuencode
                    mail=/usr/sbin/sendmail

                    # Send Backup? Would you like the backup emailed to you?
                    # Set to "y" if you do
                    sendbackup="n"
                    subject="Your MySQL Backup"
                    mailto="[email protected]"

                    # Create our backup directory if not already there
                    mkdir -p ${backupdir}
                    if [ ! -d ${backupdir} ]
                    then
                    echo "Not a directory: ${backupdir}"
                    exit 1
                    fi

                    # Dump all of our databases
                    echo "Dumping MySQL Database"
                    for database in $databases
                    do
                    $mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${database}.dump
                    done

                    # Compress all of our backup files
                    echo "Compressing Dump File"
                    for database in $databases
                    do
                    rm -f ${backupdir}/${database}.dump.gz
                    $gzip ${backupdir}/${database}.dump
                    done

                    # Send the backups via email
                    if [ $sendbackup = "y" ]
                    then
                    for database in $databases
                    do
                    $uuencode ${backupdir}/${database}.dump.gz > ${backupdir}/${database}.dump.gz.uu
                    $mail -s "$subject : $database" $mailto < ${backupdir}/${database}.dump.gz.uu
                    done
                    fi


                    # And we're done
                    ls -l ${backupdir}
                    echo "Dump Successful and Complete!"
                    exit
                    thats niceeee save as a .sh file and execute via SSH right?

                    Comment

                    • GrouchyAdmin
                      Now choke yourself!
                      • Apr 2006
                      • 12085

                      #11
                      What's this about my Ass Queue? I'm not very good with computars.

                      Comment

                      • SuckOnThis
                        So Fucking Banned
                        • Oct 2003
                        • 6844

                        #12
                        Originally posted by Juicy D. Links
                        thats niceeee save as a .sh file and execute via SSH right?
                        You can execute it with SSH or run it as a cron.

                        Just be sure to enter the correct info for 'databases', 'backupdir', 'user', and 'password'

                        Comment

                        • Juicy D. Links
                          So Fucking Banned
                          • Apr 2001
                          • 122992

                          #13
                          script above is rippeee works hotttttt thxxxx

                          Comment

                          • Juicy D. Links
                            So Fucking Banned
                            • Apr 2001
                            • 122992

                            #14
                            Originally posted by SuckOnThis
                            You can execute it with SSH or run it as a cron.

                            Just be sure to enter the correct info for 'databases', 'backupdir', 'user', and 'password'

                            yup did that

                            thxxxxxxxxxxxxx

                            Comment

                            • Juicy D. Links
                              So Fucking Banned
                              • Apr 2001
                              • 122992

                              #15
                              Dump Successful and Complete!

                              Comment

                              • HomerSimpson
                                Too lazy to set a custom title
                                • Sep 2005
                                • 13826

                                #16
                                I could write you a custom one ;)
                                Make a bank with Chaturbate - the best selling webcam program
                                Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!!

                                PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email:

                                Comment

                                • Tempest
                                  Too lazy to set a custom title
                                  • May 2004
                                  • 10217

                                  #17
                                  Originally posted by SuckOnThis
                                  Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.
                                  Sweet script...

                                  I have one I wrote in Perl that also tars all the DBs together and then Zips it. They get saved with a datestamp as well so I can roll back a few days if need be. At some point I'm going to upgrade it to also FTP the DB backup to another server so if one goes down I still have backups.

                                  Comment

                                  • GrouchyAdmin
                                    Now choke yourself!
                                    • Apr 2006
                                    • 12085

                                    #18
                                    Originally posted by Tempest
                                    Sweet script...

                                    I have one I wrote in Perl that also tars all the DBs together and then Zips it. They get saved with a datestamp as well so I can roll back a few days if need be. At some point I'm going to upgrade it to also FTP the DB backup to another server so if one goes down I still have backups.
                                    Why the hell did you use Perl?

                                    Code:
                                    -rwx------ 1 root root 3426 2007-09-29 13:16 backer.sh
                                    This little 3.5k shell script does daily, weekly, monthly, and yearly backups, compresses them all, and keeps any amount of 'snapshots' you want, and offers automated redundancy with rsync and ncftpput.

                                    Comment

                                    • bDok
                                      Confirmed User
                                      • Feb 2005
                                      • 1917

                                      #19
                                      nice shell script above.. perfect for making a gmail account for the database and shipping it off to that account daily or whenever you want to run it from the cron.

                                      quality reply there. cheers.
                                      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                                      Warriors come out to plaAAaayyy!
                                      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                                      Comment

                                      • Juicy D. Links
                                        So Fucking Banned
                                        • Apr 2001
                                        • 122992

                                        #20
                                        all this code talk is getting me HARD

                                        Comment

                                        • Juicy D. Links
                                          So Fucking Banned
                                          • Apr 2001
                                          • 122992

                                          #21
                                          all this code talk is getting me HARD

                                          Comment

                                          • Juicy D. Links
                                            So Fucking Banned
                                            • Apr 2001
                                            • 122992

                                            #22
                                            all this code talk is getting me HARD

                                            Comment

                                            • Tempest
                                              Too lazy to set a custom title
                                              • May 2004
                                              • 10217

                                              #23
                                              Originally posted by GrouchyAdmin
                                              Why the hell did you use Perl?

                                              Code:
                                              -rwx------ 1 root root 3426 2007-09-29 13:16 backer.sh
                                              This little 3.5k shell script does daily, weekly, monthly, and yearly backups, compresses them all, and keeps any amount of 'snapshots' you want, and offers automated redundancy with rsync and ncftpput.
                                              ha ha ha.. why? Cause I know perl and do a LOT of little scripts with it so it's just second nature to me... I know very little about what's already available on most servers/OSs.. and I'm not great writing cross-OS shell scripts.

                                              Couldn't find backer.sh on one of my FreeBSD and Linux servers.

                                              Comment

                                              • GrouchyAdmin
                                                Now choke yourself!
                                                • Apr 2006
                                                • 12085

                                                #24
                                                Originally posted by Tempest
                                                Couldn't find backer.sh on one of my FreeBSD and Linux servers.
                                                That would be because I made it.

                                                If you always design for the least common amount of bourne compatibility, the shells will usually work. Don't rely on linux or BSD nuances by themselves, test if you have to, and abusing awk is never wrong.

                                                Comment

                                                • papill0n
                                                  Unregistered Abuser
                                                  • Oct 2007
                                                  • 15547

                                                  #25
                                                  Originally posted by SuckOnThis
                                                  Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.



                                                  #!/bin/sh

                                                  # List all of the MySQL databases that you want to backup in here,
                                                  # each seperated by a space
                                                  databases="name of database"
                                                  # Directory where you want the backup files to be placed
                                                  backupdir=/path/to/directory

                                                  # MySQL dump command, use the full path name here
                                                  mysqldumpcmd=/usr/bin/mysqldump

                                                  # MySQL Username and password
                                                  userpassword=" --user=username --password=your password"

                                                  # MySQL dump options
                                                  dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"

                                                  # Unix Commands
                                                  gzip=/bin/gzip
                                                  uuencode=/usr/bin/uuencode
                                                  mail=/usr/sbin/sendmail

                                                  # Send Backup? Would you like the backup emailed to you?
                                                  # Set to "y" if you do
                                                  sendbackup="n"
                                                  subject="Your MySQL Backup"
                                                  mailto="[email protected]"

                                                  # Create our backup directory if not already there
                                                  mkdir -p ${backupdir}
                                                  if [ ! -d ${backupdir} ]
                                                  then
                                                  echo "Not a directory: ${backupdir}"
                                                  exit 1
                                                  fi

                                                  # Dump all of our databases
                                                  echo "Dumping MySQL Database"
                                                  for database in $databases
                                                  do
                                                  $mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${database}.dump
                                                  done

                                                  # Compress all of our backup files
                                                  echo "Compressing Dump File"
                                                  for database in $databases
                                                  do
                                                  rm -f ${backupdir}/${database}.dump.gz
                                                  $gzip ${backupdir}/${database}.dump
                                                  done

                                                  # Send the backups via email
                                                  if [ $sendbackup = "y" ]
                                                  then
                                                  for database in $databases
                                                  do
                                                  $uuencode ${backupdir}/${database}.dump.gz > ${backupdir}/${database}.dump.gz.uu
                                                  $mail -s "$subject : $database" $mailto < ${backupdir}/${database}.dump.gz.uu
                                                  done
                                                  fi


                                                  # And we're done
                                                  ls -l ${backupdir}
                                                  echo "Dump Successful and Complete!"
                                                  exit
                                                  very useful - thanks alot for posting that

                                                  Comment

                                                  • Juicy D. Links
                                                    So Fucking Banned
                                                    • Apr 2001
                                                    • 122992

                                                    #26
                                                    i make great threads

                                                    Comment

                                                    • Az A Bay Bay
                                                      Confirmed User
                                                      • Sep 2007
                                                      • 1129

                                                      #27
                                                      soRRy cant HELP "(

                                                      Home of Ed Powers and america's next hot pornstar

                                                      Comment

                                                      • GrouchyAdmin
                                                        Now choke yourself!
                                                        • Apr 2006
                                                        • 12085

                                                        #28
                                                        Originally posted by Juicy D. Links
                                                        i make great threads
                                                        Show me one.

                                                        Comment

                                                        Working...