:: 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"
Этот код создает файл, но у файла есть несколько файлов, которые я покажу ниже.
-- MySQL dump 10.13 Distrib 5.1.36, for Win32 (ia32)
--
-- Host: localhost Database: backupfiles
-- ------------------------------------------------------
-- Server version 5.1.36-community-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 */;