Skip to content

Instantly share code, notes, and snippets.

@ejhayes
Created May 30, 2013 00:31
Show Gist options
  • Save ejhayes/5674987 to your computer and use it in GitHub Desktop.
Save ejhayes/5674987 to your computer and use it in GitHub Desktop.
Export part of a table from MySQL. Someone can edit this file, send it back, then we can just overwrite the existing rows. I am doing this for a legacy database that has confusing logic to retrieve this information. Updating the rows seems to be the safest way to update this data without impacting other site functionality.
#!/bin/bash
set -e
die () {
echo >&2 "$@"
echo >&2
echo >&2 "USAGE: $0 [database]"
exit 1
}
[ "$#" -eq 1 ] || die "Database not specified"
PREFIX="TOOLTIPS_DATA"
DATE=$(date +"%b_%d_%Y")
BACKUP_FILE="${PREFIX}_${DATE}.sql"
echo "BACKING UP TOOLTIPS TO: $BACKUP_FILE"
# SectionID=15 is used by the tooltips
mysqldump --databases erictest --tables page --replace --no-create-info --where="SectionID=15" > $BACKUP_FILE
#!/bin/bash
mysql erictest < BACKUP_FILENAME_HERE.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment