Created
May 30, 2013 00:31
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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