Skip to content

Instantly share code, notes, and snippets.

@shantanuo
Created January 26, 2014 15:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shantanuo/8634172 to your computer and use it in GitHub Desktop.
Save shantanuo/8634172 to your computer and use it in GitHub Desktop.
Copy toku database to another server without using dump
#!/bin/sh
# copy the database source files to destination
dbname='palus'
source='/DATA/4GLV/tokudb/'
destip='192.168.150.137'
destuser='db'
destpass='db'
destport='3306'
destination="root@$destip:/mnt/data2/"
time mysqldump --databases $dbname --no-data | mysql -h$destip -u$destuser -p$destpass -P$destport
if [[ $? -eq 0 ]];then
mysql -Bse"SELECT CONCAT(' scp $source ', SUBSTR(internal_file_name, 3, 255), ' $destination ') FROM information_schema.TokuDB_file_map WHERE \`database\` = \"$dbname\"" > to_move.txt
fi
exit
@shantanuo
Copy link
Author

If you have the rename command available, you can use that:

rename 51fdda 2c3cd *tokudb

If you do not have the rename command available, you can do this with a simple loop:

for file in 51fdda.tokudb; do
mv ${file} ${file/51fdda/2c3cd}
done

@eyalhashai
Copy link

Also the table's database column is now called table_schema, so change:
WHERE database
to
WHERE table_schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment