SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysqldump ignore tables with certain prefix

    hi

    i'm trying to backup some databases with mysqldump but i want to ignore some tables
    with prefix phpbb_

    i have tried many solution with Like a% wildcart , 'show tables ... ' notthing work
    and no solution on google


    any help from an expert ?


    mysqldump -u username -pmypasswd database --ignore-table=database.table > database.sql

  2. #2
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    not an expert myself in SQL but found this that might help you

    mysql databasename -u[username] -p[password] -e 'show tables like "phpbb\_%"' | grep -v Tables_in | xargs mysqldump [dbname] -u [username] -p[password] > [dump_file]

    Suggest you back everything up before trying ;-)
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  3. #3
    SitePoint Member
    Join Date
    May 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx for your help but your solution don't work because i want to use mysqldump with --ignore-table

  4. #4
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    From my limited knowledge I think thats what it does

    mysql databasename -u[username] -p[password] -e 'show tables like "phpbb\_%" | Get list of all tables that start phpbb_
    grep -v Tables_in | invert the match ie now select all tables that do not start phpbb_
    xargs mysqldump [dbname] -u [username] -p[password] > [dump_file] Backup those tables

    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  5. #5
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mandes View Post
    From my limited knowledge I think thats what it does

    mysql databasename -u[username] -p[password] -e 'show tables like "phpbb\_%" | Get list of all tables that start phpbb_
    grep -v Tables_in | invert the match ie now select all tables that do not start phpbb_
    xargs mysqldump [dbname] -u [username] -p[password] > [dump_file] Backup those tables

    It actually does the opposite. I just tried it. It *only* dumps the tables with the prefix, rather than ignoring them.


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
  •