Monday, February 21, 2011

restoring mysql db from the contents of split up mysqldump

Hi my database has started to go over 2GB in backed up size, so I'm looking at options for splitting the file and then reassembling it to restore the database.

I've got a series of files from doing the following backup shell file:

DATE_STRING=\date +%u%a\

BACKUP_DIR=/home/myhome/backups

/usr/local/mysql_versions/mysql-5.0.27/bin/mysqldump --defaults-file=/usr/local/mysql_versions/mysql-5.0.27/my.cnf --user=myuser --password=mypw --add-drop-table --single-transaction mydb | split -b 100000000 - rank-$DATE_STRING.sql-;

this prodes a sequence of files like:

mydb-3Wed.sql-aa
mydb-3Wed.sql-ab
mydb-3Wed.sql-ac ...

my question is what is the corresponding sequence of commands that I need to use for linux to do the restore?

Previously I was using this command:

/usr/local/mysql_versions/mysql-5.0.27/bin/mysql --defaults-file=/usr/local/mysql_versions/mysql-5.0.27/my.cnf --user=myuser --password=mypw -D mydb < the_old_big_dbdump.sql

Any suggestions even if they don't involve split / cat would be greatly appreciated

From stackoverflow
  • I don't see why you can't just do:

    cat mydb-3Wed.sql-* | /usr/local/mysql_versions/mysql-5.0.27/bin/mysql --defaults-file=/usr/local/mysql_versions/mysql-5.0.27/my.cnf --user=myuser --password=mypw -D mydb

    The * globbing should provide the files in the sorted order, check with ls mydb-3Wed.sql-* that they actually are though.

    Eric M : Good to see proper basic shell knowledge applied.
    Simon B : Yup you're right, sorry for such a basic question. Thanks for replying, Simon B

0 comments:

Post a Comment