Sunday, April 3, 2011

Complex Database Backup

i am required to back up certain rows from certain tables from a database. often the criteria requires joins and such. what's a good way to accomplish this? (i don't have to use mysqldump).

From stackoverflow
  • If you are only interested in backing up the data, and don't need to output it as SQL, you can put your select SQL statements into a file and execute those using the mysql command, re-directing to a file like this:

    mysql my_database < queries.sql > backup.txt
    

    There are some additional options as far as delimiters and such. Check out the mysql man pages.

  • I would say just backup the entire database. That will be an easier process, and you'll more easily maintain identity integrity in case you need to restore a backup.

0 comments:

Post a Comment