Answer the question
In order to leave comments, you need to log in
How to write a script for Power Shell?
There is a cmd script that creates MySQL dumps in the MYSQL_Dumps folder:
@echo off
echo Starting Backup of Mysql Database on server
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set dt=%%c-%%a-%%b)
For /f "tokens=1-4 delims=:." %%a in ('echo %time%') do (set tm=%%a%%b%%c)
mkdir C:\MYSQL_Dumps
forfiles /p C:\MYSQL_Dumps\ /s /m *.* /d -0 /c "cmd /c del @file"
echo ===============================================================
set bkupfilename=<database_name>_%dt%.%tm%.sql
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe" --routines -u <username> -<password> -h <host> --port=<port> <database_name> > C:\MYSQL_Dumps\"%bkupfilename%"
echo ===============================================================
echo Backup Complete!
#we specify the directory where all files that we want to upload
$Dir="C:/MYSQL_Dumps"
#ftp server
$ftp = "ftp://<FTPhost>/MySQL_Dumps/"
$user = "<FTPuser>"
$pass = "<FTPpass>"
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
#list every sql server trace file
foreach($item in (dir $Dir "*")){
"Uploading $item..."
$uri = New-Object System.Uri($ftp+$item.Name)
$webclient.UploadFile($uri, $item.FullName)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question