PHP Backup Script for mySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reviewum.com
    Member
    • Mar 2004
    • 63

    #16
    Can someone give me the skinny on the steps to restore the DB using PhpMyAdmin and this file (zipped or non-zipped?)

    The only time I've sucessfully restored a DB was using Cpanel Backup and Cpanel restore... I'd love to know how to take advantage of this cool script and restore in "worst case scenerio"!

    Thanks again!
    www.reviewum.com - Teacher Reviews - Professor Ratings
    www.nifty-stuff.com - All Kinds Of Nifty Stuff (mostly LEDs)
    www.LudCon.com - Ludlow Concepts

    Comment

    • piku
      Senior Member
      • Mar 2004
      • 153

      #17
      another backup script for dbs...

      0 */2 * * * /home/username/backups/automysqlbackup.sh got this running for a very minute db (if y'all are worried, less than 100kb) to test...it seems that that last backup was 3/16/04...? did i miss something? TIA.
      my signature was deleted. i miss my signature-filled-with-helpful-dathorn-links *sniff*sniff*

      Comment

      • reviewum.com
        Member
        • Mar 2004
        • 63

        #18
        This script has been working great, sending me a zipped copy of my DB every Sunday night!

        Two questions though:

        1) As I said, this script works GREAT for getting the WHOLE DB in a (IMHO unusable) huge file, but is there a way to have the script send over a specific TABLE in CVS / EXCEL format? That would be WAY COOL, and I could use this file to run my reports, extract data, etc.!!!!

        2) For MySQL newbies like me, what are the steps in phpmyadmin to restore this file if I need to overwright a corrupt DB, or start from scratch? Can someone with a lot of patience put down a step by step?

        Thanks in advance!
        www.reviewum.com - Teacher Reviews - Professor Ratings
        www.nifty-stuff.com - All Kinds Of Nifty Stuff (mostly LEDs)
        www.LudCon.com - Ludlow Concepts

        Comment

        • piku
          Senior Member
          • Mar 2004
          • 153

          #19
          Another mysql db script... http://restkultur.ch/personal/wolf/s...kup/index.html

          Backup multiple databases and servers with different users and passwords.
          Backups can be scheduled using cron (on UNIX systems) or AT (on Windows systems).
          Create daily, weekly and monthly snpashots of your database.
          Keep the daily, weekly and monthly backups for a user-specified time.
          Archive and compress the SQL files (*.tar.gz).
          Creates a detailed report of everything that has been done.
          Reports can be mailed to you or any other user- specified email- address, saved to disk or displayed in browser.
          Generated SQL files can be mailed to you or any other user-specified email-address.
          Generated SQL files can be uploaded by FTP to any user-specified FTP server.
          Choose to create SQL files for each table or one for each database.
          No system calls, everything in 100% pure PHP. PHP Safe-mode compatible.

          -------------

          update: this thing is GREAT. you can backup any DB in your different cpanel accounts if its in the same server (ie. localhost), as well as exclude tables that you dont want from particular DB (from a particular cpanel account).

          one thing though...

          Code:
          // Set this to TRUE (recommended) if you want to delete the .sql files after archiving.
          $cfg['archive_del_sql'] = TRUE;
          even w/ this on--it seems that it doesn't delete the local *.tar.gz. i have this set to true since i'm FTPing the files to a different server. i'll give an update once i get word from the author about this little dillema.
          Last edited by piku; 05-18-2004, 03:28 PM.
          my signature was deleted. i miss my signature-filled-with-helpful-dathorn-links *sniff*sniff*

          Comment

          • piku
            Senior Member
            • Mar 2004
            • 153

            #20
            update from alain wolf RE tar archives not being deleted...

            the setting "$cfg['archive_del_sql']" just deletes the plain SQL-files not the tar-archives. Features to delete the archives, are planned, but have not been implemented by now, partly beause i like to have a better confirmation of a successfull ftp-upload and/or mail-delivery before the local archive-file will be deleted.

            you will have to wait for the next release or so. altough right now i can't tell you when this will be. unfortunately i had not much time lately to work on the backup script.

            my only suggestion would be to play around with the values for keeping the backups (days/months/years) to keep the archive files small.
            ...there ya go. i set mine to 2/2/2 @ the moment to keep the size small
            my signature was deleted. i miss my signature-filled-with-helpful-dathorn-links *sniff*sniff*

            Comment

            • reviewum.com
              Member
              • Mar 2004
              • 63

              #21
              Any answer to this question:

              Is there a way to have the script send over a specific TABLE in CVS / EXCEL format? That would be WAY COOL, and I could use this file to run my reports, extract data, etc.!!!!
              www.reviewum.com - Teacher Reviews - Professor Ratings
              www.nifty-stuff.com - All Kinds Of Nifty Stuff (mostly LEDs)
              www.LudCon.com - Ludlow Concepts

              Comment

              • Jonathan
                Senior Member
                • Mar 2004
                • 1229

                #22
                can't say I know
                "How can someone be so distracted yet so focused?"
                - C

                Comment

                • chrisd
                  Member
                  • Mar 2004
                  • 44

                  #23
                  Originally posted by reviewum.com
                  Any answer to this question:

                  Is there a way to have the script send over a specific TABLE in CVS / EXCEL format?
                  Normally you would do a SELECT * INTO OUTFILE "/home/user/file.csv" FROM table_name

                  However, that requires elevated rights - which aren't available here.

                  You could probably come close with a PHP script that loops through the table and writes it out to the file system - although I haven't seen one specifically for that.

                  Comment

                  • piku
                    Senior Member
                    • Mar 2004
                    • 153

                    #24
                    Originally posted by reviewum.com
                    Any answer to this question:

                    Is there a way to have the script send over a specific TABLE in CVS / EXCEL format? That would be WAY COOL, and I could use this file to run my reports, extract data, etc.!!!!
                    take a look at the last script i posted by alain wolf. you have to prolly change the "sql" to "csv" part. but for sure, you can select which tables you want to be backed-up; so there's half the solution.
                    my signature was deleted. i miss my signature-filled-with-helpful-dathorn-links *sniff*sniff*

                    Comment

                    • DWalley
                      Junior Member
                      • Jul 2004
                      • 25

                      #25
                      I have it in a folder call /backup and permission at 755

                      This comes on the screen when I execute the page. I get an email and a sql file but nothing is in the file.

                      Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/autoplac/public_html/backup/backup.php on line 66




                      Help someone.
                      Last edited by DWalley; 07-11-2004, 09:36 PM.

                      Comment

                      • -Oz-
                        Senior Member
                        • Mar 2004
                        • 545

                        #26
                        If I had to guess I don't think its connecting to the database properly.
                        Dan Blomberg

                        Comment

                        • kuty
                          Junior Member
                          • Mar 2004
                          • 4

                          #27
                          Originally posted by Josh
                          To set this up in cron you should set the time you would like to run the script and enter this command:
                          Script works for me if I run manually:
                          php /home/username/path/to/file
                          from shell. DB is dumped and transfered to remote FTP server.

                          BUT, when I put the same into crontab, it do nothing! What might be the problem?

                          Thanks!

                          Comment

                          • piku
                            Senior Member
                            • Mar 2004
                            • 153

                            #28
                            Originally posted by Slider
                            For a few of my sites, I run a shell script that exports the databases of my choice, TAR's them and then FTP's them to another server of my choice. It runs off a cron job every night at 4AM CST. I cannot post them from work right now, but when I get home, I can post them up here for anyone who wants to use them. When I first created them back last year, I got a lot of help from people in this forum and I think it's time to start giving some help back...
                            Still got that script? Wondering if its working w/ the newly updated servers... TIA
                            my signature was deleted. i miss my signature-filled-with-helpful-dathorn-links *sniff*sniff*

                            Comment

                            • powelly
                              Junior Member
                              • Apr 2007
                              • 1

                              #29
                              Hi,

                              I'm trying to get this script working its backing up the database to the server without any problems, its able to send the file, but one i receive it its seems corrupt. the .gz can not be unzipped or if i don't zip it the .sql file looks like this.

                              Code:
                              filename="abcstudio_bck-20070406-1835.sql"
                              Content-Transfer-Encoding: base64
                              
                              RFJPUCBUQUJMRSBJRiBFWElTVFMgdGVzdDsKQ1JFQVRFIFRBQkxFIHRlc3QgKAogICAgaGkgdmFy
                              Y2hhcig3KSBOT1QgTlVMTAopOwoKSU5TRVJUIElOVE8gdGVzdCBWQUxVRVMgKCdibGFoJyk7CklO
                              U0VSVCBJTlRPIHRlc3QgVkFMVUVTICgnYmx1ZScpOwoKCg==
                              Any ideas?

                              Comment

                              • erick_p
                                Junior Member
                                • May 2007
                                • 2

                                #30
                                Why would you need a PHP script when it's only one command away to "mysqlhotcopy"? No PHP script can beat the speed of that. It backs up my 5 million rows in 2 seconds.

                                Comment

                                Working...