MyDumper: Difference between revisions
From fakedWiki
(Created page with "== Restore == <nowiki>#!/bin/bash if [ -z $1 ]; then echo "Usage: $0 </path/to/mydumper/backup> [database-name]" exit 1 fi FINDNAME="*" if [ -n ${2} ]; then FINDNAME=...") |
m (1 revision imported) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 15: | Line 15: | ||
DB=$(basename "${DBFILE}" | sed 's/_schema\.sql\.gz//') | DB=$(basename "${DBFILE}" | sed 's/_schema\.sql\.gz//') | ||
echo "Restoring schema for database '${DB}' from ${DBFILE}" | echo "Restoring schema for database '${DB}' from ${DBFILE}" | ||
zcat ${DBFILE} | mysql ${DB} | |||
for TFILE in $(find ${1} -iname "${DB}.*.sql.gz"); do | for TFILE in $(find ${1} -iname "${DB}.*.sql.gz"); do | ||
TABLE=$(basename "${TFILE}" | sed -n "s/${DB}\.\(.*\)\.sql\.gz/\1/p") | TABLE=$(basename "${TFILE}" | sed -n "s/${DB}\.\(.*\)\.sql\.gz/\1/p") |
Latest revision as of 20:10, 26 August 2016
Restore
#!/bin/bash if [ -z $1 ]; then echo "Usage: $0 </path/to/mydumper/backup> [database-name]" exit 1 fi FINDNAME="*" if [ -n ${2} ]; then FINDNAME="${2}" fi for DBFILE in $(find ${1} -iname "${FINDNAME}_schema.sql.gz"); do DB=$(basename "${DBFILE}" | sed 's/_schema\.sql\.gz//') echo "Restoring schema for database '${DB}' from ${DBFILE}" zcat ${DBFILE} | mysql ${DB} for TFILE in $(find ${1} -iname "${DB}.*.sql.gz"); do TABLE=$(basename "${TFILE}" | sed -n "s/${DB}\.\(.*\)\.sql\.gz/\1/p") echo "Restoring table ${DB}.${TABLE}..." zcat ${TFILE} | mysql ${DB} done done