Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2015
    Posts
    165
    Plugin Contributions
    0

    Default backing up database tables separately

    ok so i am using the command line in ssh to backup the database

    mysqldump -u [USERNAME] -p[PASSWORD] [DATABASE NAME] > [BACKUPFILE NAME]

    i am also backing up each table individually with the command line

    mysqldump -u <db_username> -p db_name table_name > table_name.sql

    the problem is there are 144 tables and it took me 15 minutes

    is there a swift one command liner to do this where each database table is also named the table name

    address_book > address_book.sql
    address_format > address_format.sql
    etc.

    our server also has a nightly backup for the entire site and database

    the reasoning behind is last time we moved to a different server and imported the entire database, there were errors galore in a lot of tables and luckily it was fixed. i'm thinking on our next server move, if there is a problem importing the entire db in one chunk, i can import each table since they are smaller files

    thanks in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,696
    Plugin Contributions
    123

    Default Re: backing up database tables separately

    You can just build a script to do this. The table names are in includes/database_tables.php.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Mar 2015
    Posts
    165
    Plugin Contributions
    0

    Default Re: backing up database tables separately

    there are other database tables though created by "plugins" that aren't listed in that file

  4. #4
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: backing up database tables separately

    Quote Originally Posted by swguy View Post
    You can just build a script to do this. The table names are in includes/database_tables.php.
    Ehhh, not 100% true otherwise there would not be 144 tables. In that script would suggest pulling the list of tables and then cycling through those. Small "problem" with that though too is that a single database may be used for more than one store and also a plugin may not use/enforce the DB_PREFIX.
    Personally, it sounds like the issue really was that when transferring from one database to the other that the source database was operated looser than the destination database. That allowed the source database to have problems that were undetected until either initially loaded (even into the same server) into a database or otherwise so accessed. Sounding like a nay sayer, I would perceive that this individual table scenario would actually introduce more potential issues. e.g. a table gets updated in the database, that table is independently exported, but the records in it now point to either non-existent information because in updating the one table there actually were others that were updated and not also exported...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,691
    Plugin Contributions
    9

    Default Re: backing up database tables separately

    i am also of the opinion that solving the database import is the best solution. the fact that you had a problem (i'm guessing) there is more about the mysql config than of your db backup. a full on db backup is always, IMO, your best solution.

    if you want to do a script; i too am not a fan of hard coded table names in a file.

    you can get all of the your table names by using a php script as such:

    PHP Code:
        require 'includes/application_top.php';
        
    $name 'Tables_in_' DB_DATABASE;
        
    $tables $db->Execute('show tables');
        foreach (
    $tables as $table) {
            
    // here you can do you backup of each table
            
    echo "-------->" $table[$name] . "<---------<br>";
        } 
    hopefully that gives you enough to go on.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 

Similar Threads

  1. v139h Backing Up Database
    By traytray in forum General Questions
    Replies: 5
    Last Post: 1 Jul 2012, 11:36 PM
  2. Importing tables separately
    By waterbender in forum Upgrading from 1.3.x to 1.3.9
    Replies: 2
    Last Post: 16 May 2010, 06:04 PM
  3. Create Database, Tables and Drop Database or Tables
    By elwood cordery in forum General Questions
    Replies: 3
    Last Post: 17 Aug 2009, 04:03 PM
  4. Backing up and restoring particular tables?
    By OK Computer in forum General Questions
    Replies: 5
    Last Post: 12 Nov 2008, 12:09 PM
  5. Backing up database
    By besheer in forum General Questions
    Replies: 8
    Last Post: 4 Sep 2006, 02:12 AM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR