{"id":355,"date":"2015-10-12T10:32:03","date_gmt":"2015-10-12T17:32:03","guid":{"rendered":"http:\/\/infinitedisorder.com\/?p=355"},"modified":"2015-12-04T12:44:11","modified_gmt":"2015-12-04T19:44:11","slug":"restore-of-mysqldump-taken-with-all-databases","status":"publish","type":"post","link":"https:\/\/infinitedisorder.com\/?p=355","title":{"rendered":"Restore of mysqldump taken with &#8211;all-databases"},"content":{"rendered":"<p>This\u00a0gotcha always gets me and when I google it I get nowhere.<\/p>\n<p>Backup all databases:<br \/>\n<code>BACKUP_FILE=`\/mnt\/backups\/all_databases_`date -I`-`echo\u00a0$RANDOM\u00a0%\u00a01000\u00a0|\u00a0bc`.sql`<br \/>\nmysqldump\u00a0-u\u00a0root -h 127.0.0.1 --all-database &gt;\u00a0$BACKUP_FILE<\/code><\/p>\n<p>Restore a specific database:<br \/>\n<code>RESTORE_FILE=`ls -tr \/mnt\/backups\/*.sql | tail -n 1`<br \/>\nmysql -u root -h 127.0.0.1<br \/>\ndrop database db_name;<br \/>\ncreate database db_name;<br \/>\nexit<br \/>\nmysql -u root -h 127.0.0.1 db_name &lt; $RESTORE_FILE<\/code><br \/>\nnote: when restoring a database, you may need to use the same DB name as the original<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This\u00a0gotcha always gets me and when I google it I get nowhere. Backup all databases: BACKUP_FILE=`\/mnt\/backups\/all_databases_`date -I`-`echo\u00a0$RANDOM\u00a0%\u00a01000\u00a0|\u00a0bc`.sql` mysqldump\u00a0-u\u00a0root -h 127.0.0.1 &#8211;all-database &gt;\u00a0$BACKUP_FILE Restore a specific database: RESTORE_FILE=`ls -tr \/mnt\/backups\/*.sql | tail -n 1` mysql -u root -h 127.0.0.1 drop database db_name; create database db_name; exit mysql -u root -h 127.0.0.1 db_name &lt; $RESTORE_FILE note: when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-355","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355"}],"version-history":[{"count":5,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions"}],"predecessor-version":[{"id":419,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions\/419"}],"wp:attachment":[{"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infinitedisorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}