Read more

Howto transfer a single mysql table between several deployment stages

Martin Straub
September 27, 2012Software engineer at makandra GmbH

Example task: Multiply the table holidays between several stages.

  1. Open two terminals:

    shell-for stage_1
    shell-for stage_2
    
  2. Get the stage1 and stage2 MySQL credentials:

    cat /opt/www/the_stage.host.tld/current/config/database.yml
    cat config/database.yml # should do it
    
  3. Dump the table to a path reachable by the stage2 user (e.g. home):

    mysqldump -h mysql1 -u stage_1_user -p stage_1_database table_name > ~/table_name_dump.mysql # Select certain records using --where "some_id > 666"
    

    (-h stands for hostname and it is in deed 'mysql1')

  4. Import the dump:

    mysql -h mysql1 -u stage_2_user -p stage_2_database < /home/stage_1_user/table_name_dump.mysql # attention to stage1 and stage2
    
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Note that importing a table overwrites an existing table. There won't be a magic merge.

Posted by Martin Straub to makandra dev (2012-09-27 12:13)