Last active
December 31, 2015 01:09
-
-
Save anytizer/7912203 to your computer and use it in GitHub Desktop.
Backup a MySQL databases in 4 different ways.
1. Full database backup (contains everything you need to restore the database)
2. Database structure only backup (includes VIEWs as well)
3. Data only backup - contains INSERT statements only
4. Routines only backup (stored procedures, user defined functions)
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
| @echo off | |
| SET HOSTNAME=localhost | |
| SET USERNAME=root | |
| SET PASSWORD=password | |
| SET DATABASE=database | |
| REM Backup everything | |
| mysqldump --routines -h%HOSTNAME% -u%USERNAME% -p%PASSWORD% %DATABASE% > %DATABASE%-all.dmp | |
| REM Backup table structures only, includes VIEWs as well | |
| mysqldump --no-data -h%HOSTNAME% -u%USERNAME% -p%PASSWORD% %DATABASE% > %DATABASE%-structure.dmp | |
| REM Backup data only | |
| mysqldump --no-create-info --compact -h%HOSTNAME% -u%USERNAME% -p%PASSWORD% %DATABASE% > %DATABASE%-data-only.dmp | |
| REM Backup routines only | |
| mysqldump --routines --no-create-info --no-data -h%HOSTNAME% -u%USERNAME% -p%PASSWORD% %DATABASE% > %DATABASE%-routines.dmp | |
| pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment