Welcome, Guest
Section to post tutorials on how to manage and read your eComics

TOPIC: How to backup MySQL database

How to backup MySQL database 3 years 10 months ago #37736

  • pweasel
  • pweasel's Avatar
  • Offline
  • Expert Boarder
  • Posts: 123
  • Thank you received: 18
  • Karma: 8
Here's a small windows command line script to backup and rar-compress said mysql library.
It assumes a few folders, like "C:\program files\MySQL\MySQL Server 5.6\bin" for the mysql bin folder, "W:/MySql" for a destination folder and winrar to be installed on "C:\program files\WinRAR".

Hope it put minds at ease as it did to mine.

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC ^Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
    IF %%A GTR 0 (
	SET Day=%%A
	SET Hour=%%B
	SET Min=%%C
	SET Month=%%D
	SET Sec=%%E
	SET Year=%%F
    )
)


if %Month% LSS 10 set Month=0%Month%
if %Day% LSS 10 set Day=0%Day%
if %Min% LSS 10 set Minute=0%Minute%
if %Hour% LSS 10 set Hour=0%Hour%

rem set now=%year%-%month%-%day%_%hour%-%min%-%sec%
set now=%year%-%month%-%day%
set now=%now%

"C:\program files\MySQL\MySQL Server 5.6\bin\mysqldump" --opt -uuser -ppassword comicdb --result-file=W:/MySql/comicdb-%now%.sql
"C:\program files\WinRAR\rar" m -m5 -dh -y -ibck W:\MySql\comicdb-%now%.sql.rar W:\MySql\comicdb-%now%.sql





CRW 0.9.178 x64 on Win10
CRA 1.80 on Nexus 10
The administrator has disabled public write access.
The following user(s) said Thank You: boshuda
Time to create page: 0.143 seconds

Who's Online

We have 249 guests and 2 members online