Saturday, March 29, 2014

MySQL backups and restore

The general syntax for MySQL backups using mysqldump tool is

Backup:

$mysqldump -h [RDS instance info] -u [rds_user_name] -p[rds_ password] --socket=[if_different_from_default] -P=[port_if_different_from_3306] [database_name] > rdsdump.sql

Single DB Backup:

$mysqldump -h [RDS instance info] -u [rds_user_name] -p[rds_ password] --socket=[if_different_from_default] -P=[port_if_different_from_3306] [database_name1] > db1dump.sql

Multiple DB Backups:

$mysqldump -h [RDS instance info] -u [rds_user_name] -p[rds_ password] --socket=[if_different_from_default] -P=[port_if_different_from_3306] [database_name1] [database_name2] > db1db2dump.sql

All DB Backups:

$mysqldump -h [RDS instance info] -u [rds_user_name] -p[rds_ password] --socket=[if_different_from_default] -P=[port_if_different_from_3306] --all-databases > alldbdump.sql

Dump of specific table:

$mysqldump -h [RDS instance info] -u [rds_user_name] -p[rds_ password] --socket=[if_different_from_default] -P=[port_if_different_from_3306] [database_name] [table_name] > db_table_name_dump.sql

Restore from dump:

$mysqldump -h [RDS instance info] -u [rds_user_name] -p[rds_ password] --socket=[if_different_from_default] -P=[port_if_different_from_3306] [database_name] < rdsdump.sql

2 comments:

  1. I use this and it works famously: http://sourceforge.net/projects/automysqlbackup/ it even encrypts as well. You just need to create a restore script is all.....

    ReplyDelete
    Replies
    1. @Paul Roesler, Thanks for the link, will check it out. Meanwhile, have you tried - http://www.percona.com/software/percona-xtrabackup?

      Delete