Task:
Have a MariaDB/MySQL multi-database backup. Need to isolate one specific backup for restoration of elements.
Steps:
1. Locate/report the database contained in the backup:
$ cd /backups/
$ grep -n 'Database:' localhost_backups_20250503.sql
21:-- Database: `abcefgxyz_63woIgv`
374599:-- Database: `abcefgxyz_abcJ3XG`
592027:-- Database: `abcefgxyz_defAsJd`
1056024:-- Database: `abcefgxyz_gHja7yl`
1144043:-- Database: `pqrstuvxyz_WVUTS`
1202054:-- Database: `pqrstuvxyz_MNOPQ`
1203096:-- Database: `zyabcxwvu_GFedc`
1232509:-- Database: `zyabcxwvu_ABcdEF`
1233812:-- Database: `zyabcxwvu_LKMPTu`
...
2. Split a specific database from out of the middle:
$ sed -n '/^-- Database: `pqrstuvxyz_WVUTS`/,/^-- Database: `/p' localhost_backups_20250503.sql > pqrstuvxyz_WVUTS.sql
3. Manually add back the header items from the top of the file.
$ vi localhost_backups_20250503.sql
<copied top lines to clipboard>
$ vi pqrstuvxyz_WVUTS.sql
<i> (insert mode)
<pasted>
<esc>:wq (to save and exit)
previous page
|