Last active
September 30, 2016 14:56
-
-
Save maoizm/a8cfbad867149d5cb3a802a1bf7b1ab0 to your computer and use it in GitHub Desktop.
Backs up Joomla database with correct SQL commands to restore on live system without rights to DROP tables and databases
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 | |
mysqldump -hHost -PportOfMYSQLserver -uUserName -pPassword DatabaseName --no-create-db --skip-add-drop-table | sed -r -e "s/CREATE TABLE (`[^`]+`)/CREATE TABLE IF NOT EXISTS \1/g" -e "s/LOCK TABLES (`[^`]+`)/DELETE FROM \1;\nLOCK TABLES \1/g" | gzip > "$(date +%Y%m%d_%H%M%S)_backup.sql.gz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is for sed in Windows command line
(double quotes used instead of single quotes in Linux environment)
mysqldump
-h**hostOfMySQLserver** -P**portOfMySQLserver** -u**userName** -p**password** databaseName--no-create-db --skip-add-drop-table | sed -r -e "s/CREATE TABLE (
[^`]+`)/CREATE TABLE IF NOT EXISTS \1/g" -e "s/LOCK TABLES (`[^`]+)/DELETE FROM \1;\nLOCK TABLES \1/g" | gzip > "$(date +%Y%m%d_%H%M%S)-**_databaseName_**.sql.gz"