mysqldump script is not back up in this script
:: MySQLBackup By Matt Moeller
:: RED OLIVE DESIGN INC.
SET backupdate=%DATE:~10,4%-%DATE:~7,2%-%DATE:~4,2%-%TIME:~0,2%-%TIME:~3,2%
:: MySQl DB user
set dbuser=dumpuser
:: MySQl DB users password
set dbpass=t5794
:: Switch to the MySQL data directory and collect the folder names
pushd "E:\mysqlbackup"
:: Loop through the folders and use the fnames for the sql filenames, collects all databases automatically this way
echo "hello"
echo "Pass each name to mysqldump.exe and output an individual .sql file for each"
FOR /D %%F IN (*) DO (
"C:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump.exe" --user=%dbuser% --password=%dbpass% --databases %%F > "E:\mysqlbackup\backupfiles\%%F.%backupdate%.sql"
)
echo "All done, pretty slick eh"
This code it create file but the file have a few in for mation i show it below How can i fix it
-- MySQL dump 10.13 Distrib 5.1.36, for Win32 (ia32)
--
-- Host: localhost Database: backupfiles
-- ------------------------------------------------------
-- Server version 5.1.36-commu开发者_如何学Pythonnity-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
Check the dump:
-- Host: localhost Database: backupfiles
Seems like you are not passing the database name(s) correctly. I guess there is something wrong with the loop calling mysqldump, but I have no clue of windows batch files.
Look at how the script is working:
pushd "E:\mysqlbackup"
This changes your current directory to E:\mysqlbackup
. You then loop over all subdirectories in E:\mysqlbackup
with
FOR /D %%F IN (*) DO (
however, given your dump output, most likely the ONLY thing in E:\mysqlbackup
is another subdirectory called backupfiles
. Unless you have a database called "backupfiles", that'll never dump anything.
For this to work, you have to manually create a subdirectory for EVERY database you want to dump, before you run this script. Otherwise the script has no method of determining what your databases are, and will only ever create a dump of the non-existing "backupfiles" database.
This:
pushd "E:\mysqlbackup"
Should be changed to:
pushd "C:\ProgramData\MySQL\MySQL Server 5.6\data"
or whatever version and folder you Mysql Data-folder is in.
精彩评论