Jump to content

[Release] MySQL DB backup v1.1.


Recommended Posts

Damn, thanks man. I am not using any host it's all here on my home box. I did notice you're original post seems to have changed a bit, is an update reccomended?

 

 

####UPDATE#####

SO I did some extensive googling and although I never found a specific case of my error I did find many similar which led me to look in "MySQL Server\my.ini", lo and behold right there was no-beep right in the first line after the [client] class.

 

Weird Huh?

 

Glad to see you got to the bottom of the problem :) .  With hindsight I guess wingrep may have found it for you as well.

 

The update in the original post should only be to add a couple more options for mysqldump so that events and triggers also get dumped out (if you have any).  There should be no harm adding the parameters and it means the dump is a bit more comprehensive rather than just the databases and their objects / data.

Link to comment
Share on other sites

  • 3 weeks later...

Hi Rimblock, 

 

I'm having problems setting this up.

 

Whenever I run the batch file I get this error with 'pause' added:

C:\Users\Administrator\Desktop>SET BackupDir="D:\Backup_DB"


C:\Users\Administrator\Desktop>SET mysqldir="D:\Program Files\MySQL\MySQL Workbe
nch 6.2 CE"


C:\Users\Administrator\Desktop>SET mysqlschema=Epoch_Database


C:\Users\Administrator\Desktop>SET mysqlpassword=xxxxxx


C:\Users\Administrator\Desktop>SET mysqluser=root


C:\Users\Administrator\Desktop>SET housekeepafter=5


C:\Users\Administrator\Desktop>For /F "tokens=2-4 delims=/ " %a in ('date /t') d
o (set mydate=%c-%a-%b )


C:\Users\Administrator\Desktop>(set mydate=-10-2014 )


C:\Users\Administrator\Desktop>For /F "tokens=1-2 delims=/:" %a in ("21:24:45.87
") do (set mytime=%a.%b )


C:\Users\Administrator\Desktop>(set mytime=21.24 )


C:\Users\Administrator\Desktop>set hour=21


C:\Users\Administrator\Desktop>if "2" == " " set hour=01


C:\Users\Administrator\Desktop>set datestamp=-0/-01_2124


C:\Users\Administrator\Desktop>c:


C:\Users\Administrator\Desktop>cd "D:\Program Files\MySQL\MySQL Workbench 6.2 CE
"


C:\Users\Administrator\Desktop>mysqldump -u Epoch_User -pxxxxxx --databases root
 --routines --events --triggers --quick   1>"D:\Backup_DB"\root_backup.-0/-01_21
24.sql
The system cannot find the path specified.


C:\Users\Administrator\Desktop>forfiles -p "D:\Backup_DB" -s -m *.sql -d -5 -c "
cmd /c del @path"
ERROR: No files found with the specified search criteria.


C:\Users\Administrator\Desktop>pause
Press any key to continue . . .

 

I checked db user permissions and even tried root which has full access and still get the same error. I have checked the file paths and they are valid.

 

 

My copy of your batch file with password xxxxx'd out is :

@REM *** PARAMETERS/VARIABLES ***
SET BackupDir="D:\Backup_DB"
SET mysqldir="D:\Program Files\MySQL\MySQL Workbench 6.2 CE"
SET mysqlschema=Epoch_Database
SET mysqlpassword=xxxxxx
SET mysqluser=root
SET housekeepafter=5


For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a.%%b)


set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
set datestamp=%date:~10,4%-%date:~4,2%-%date:~7,2%_%hour%%time:~3,2%


@REM *** EXECUTION ***
@REM Change to mysqldir
c:
cd %mysqldir%


@REM dump/backup ALL database, this is all in one line
mysqldump -u %mysqluser% -p%mysqlpassword% --databases %mysqlschema% --routines --events --triggers --quick  >%BackupDir%\%mysqlschema%_backup.%datestamp%.sql


@REM - Housekeeping
forfiles -p %BackupDir% -s -m *.sql -d -%housekeepafter% -c "cmd /c del @path"
pause

 

Am normally pretty good at following stuff like this and have gone over and over and double triple checked everything from your OP but, can't seem to get anywhere....

 

Any advice?

Link to comment
Share on other sites

 

Hi Rimblock, 

 

I'm having problems setting this up.

 

Whenever I run the batch file I get this error with 'pause' added:

C:\Users\Administrator\Desktop>SET BackupDir="D:\Backup_DB"


C:\Users\Administrator\Desktop>SET mysqldir="D:\Program Files\MySQL\MySQL Workbe
nch 6.2 CE"


C:\Users\Administrator\Desktop>SET mysqlschema=Epoch_Database


C:\Users\Administrator\Desktop>SET mysqlpassword=xxxxxx


C:\Users\Administrator\Desktop>SET mysqluser=root


C:\Users\Administrator\Desktop>SET housekeepafter=5


C:\Users\Administrator\Desktop>For /F "tokens=2-4 delims=/ " %a in ('date /t') d
o (set mydate=%c-%a-%b )


C:\Users\Administrator\Desktop>(set mydate=-10-2014 )


C:\Users\Administrator\Desktop>For /F "tokens=1-2 delims=/:" %a in ("21:24:45.87
") do (set mytime=%a.%b )


C:\Users\Administrator\Desktop>(set mytime=21.24 )


C:\Users\Administrator\Desktop>set hour=21


C:\Users\Administrator\Desktop>if "2" == " " set hour=01


C:\Users\Administrator\Desktop>set datestamp=-0/-01_2124


C:\Users\Administrator\Desktop>c:


C:\Users\Administrator\Desktop>cd "D:\Program Files\MySQL\MySQL Workbench 6.2 CE
"


C:\Users\Administrator\Desktop>mysqldump -u Epoch_User -pxxxxxx --databases root
 --routines --events --triggers --quick   1>"D:\Backup_DB"\root_backup.-0/-01_21
24.sql
The system cannot find the path specified.


C:\Users\Administrator\Desktop>forfiles -p "D:\Backup_DB" -s -m *.sql -d -5 -c "
cmd /c del @path"
ERROR: No files found with the specified search criteria.


C:\Users\Administrator\Desktop>pause
Press any key to continue . . .

 

I checked db user permissions and even tried root which has full access and still get the same error. I have checked the file paths and they are valid.

 

 

My copy of your batch file with password xxxxx'd out is :

@REM *** PARAMETERS/VARIABLES ***
SET BackupDir="D:\Backup_DB"
SET mysqldir="D:\Program Files\MySQL\MySQL Workbench 6.2 CE"
SET mysqlschema=Epoch_Database
SET mysqlpassword=xxxxxx
SET mysqluser=root
SET housekeepafter=5


For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a.%%b)


set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
set datestamp=%date:~10,4%-%date:~4,2%-%date:~7,2%_%hour%%time:~3,2%


@REM *** EXECUTION ***
@REM Change to mysqldir
c:
cd %mysqldir%


@REM dump/backup ALL database, this is all in one line
mysqldump -u %mysqluser% -p%mysqlpassword% --databases %mysqlschema% --routines --events --triggers --quick  >%BackupDir%\%mysqlschema%_backup.%datestamp%.sql


@REM - Housekeeping
forfiles -p %BackupDir% -s -m *.sql -d -%housekeepafter% -c "cmd /c del @path"
pause

 

Am normally pretty good at following stuff like this and have gone over and over and double triple checked everything from your OP but, can't seem to get anywhere....

 

Any advice?

 

You have your path pointing to MySQL workbench in which itself is another program.  Needs to point to the server. Example: SET mysqldir="C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin"

Link to comment
Share on other sites

You have your path pointing to MySQL workbench in which itself is another program.  Needs to point to the server. Example: SET mysqldir="C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin"

Hi, I have also tried C:\xampp\mysql\bin as I'm using xampp but, that doesn't work either. I can confirm that is the folder where mysqldump.exe resides....

 

Any more suggestions?

Link to comment
Share on other sites

Post the batch file that you intend to use.  And I'll take a look. Also post your mysql.ini.

Hi, thanks for your help.....maybe this is why I'm having a problem but, I don't have a mysql.ini

 

I have installed using xampp and phpmyadmin as per the Epoch installation instructions posted here:

Link to comment
Share on other sites

ok, thanks. Here is the my.ini:

# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# You can copy this file to
# C:/xampp/mysql/bin/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:/xampp/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.


# The following options will be passed to all MySQL clients
[client] 
# password       = your_password 
port            = 3306 
socket          = "C:/xampp/mysql/mysql.sock"




# Here follows entries for some specific programs 


# The MySQL server
[mysqld]
port= 3306
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql" 
tmpdir = "C:/xampp/tmp" 
datadir = "C:/xampp/mysql/data"
pid_file = "mysql.pid"
# enable-named-pipe
key_buffer = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log_error = "mysql_error.log"


# Change here for bind listening
# bind-address="127.0.0.1" 
# bind-address = ::1          # for ipv6


# Where do all the plugins live
plugin_dir = "C:/xampp/mysql/lib/plugin/" 


# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# 
# commented in by lampp security
#skip-networking
skip-federated


# Replication Master Server (default)
# binary logging is required for replication
# log-bin deactivated by default since XAMPP 1.4.11
#log-bin=mysql-bin


# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1


# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin




# Point the following paths to different dedicated disks
#tmpdir = "C:/xampp/tmp"
#log-update = /path-to-dedicated-directory/hostname


# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000


# Comment the following if you are using InnoDB tables
#skip-innodb
innodb_data_home_dir = "C:/xampp/mysql/data"
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = "C:/xampp/mysql/data"
#innodb_log_arch_dir = "C:/xampp/mysql/data"
## You can set .._buffer_pool_size up to 50 - 80 %
## of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
## Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50


## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'
#collation_server=utf8_unicode_ci
#character_set_server=utf8
#skip-character-set-client-handshake
#character_sets-dir="C:/xampp/mysql/share/charsets"


[mysqldump]
quick
max_allowed_packet = 16M


[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates


[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M


[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M


[mysqlhotcopy]
interactive-timeout

 

This is the bat file with the password changed to xxxxxx:

@REM *** PARAMETERS/VARIABLES ***
SET BackupDir="D:\Backup_DB"
SET mysqldir="C:\xampp\mysql\bin"
SET mysqlschema=epoch_database
SET mysqlpassword=xxxxxx
SET mysqluser=root
SET housekeepafter=5


For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a.%%b)


set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
set datestamp=%date:~10,4%-%date:~4,2%-%date:~7,2%_%hour%%time:~3,2%


@REM *** EXECUTION ***
@REM Change to mysqldir
c:
cd %mysqldir%


@REM dump/backup ALL database, this is all in one line
mysqldump -u %mysqluser% -p%mysqlpassword% --databases %mysqlschema% --routines --events --triggers --quick  >%BackupDir%\%mysqlschema%_backup.%datestamp%.sql


@REM - Housekeeping
forfiles -p %BackupDir% -s -m *.sql -d -%housekeepafter% -c "cmd /c del @path"
pause

 

Thanks for your help with this. 

Link to comment
Share on other sites

Looks correct from what I can tell. Only thing I would try is to create a new user in your database and give full permissions. I wouldn't suggest running anything as root.  Double-check your database name, password, user. Should match your hiveExt.ini in your server. I'll setup a quick xampp on my test server and see if I run into the same problem.

Link to comment
Share on other sites

Looks correct from what I can tell. Only thing I would try is to create a new user in your database and give full permissions. I wouldn't suggest running anything as root.  Double-check your database name, password, user. Should match your hiveExt.ini in your server. I'll setup a quick xampp on my test server and see if I run into the same problem.

Cheers man. I'll try that right now and report back.

 

EDIT: :( No joy. Just set up a user with full permissions called db_backup and stil get the specified path not valid message....

Link to comment
Share on other sites

Setup on my in-home server and basically ran your batch file as root no problems?

@REM *** PARAMETERS/VARIABLES ***
SET BackupDir="C:\Users\Administrator\Desktop\Backup_DB"
SET mysqldir="C:\xampp\mysql\bin"
SET mysqlschema=dayz_overpoch
SET mysqlpassword=robio376
SET mysqluser=root
SET housekeepafter=5
 
 
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a.%%b)
 
 
set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
set datestamp=%date:~10,4%-%date:~4,2%-%date:~7,2%_%hour%%time:~3,2%
 
 
@REM *** EXECUTION ***
@REM Change to mysqldir
c:
cd %mysqldir%
 
 
@REM dump/backup ALL database, this is all in one line
mysqldump -u %mysqluser% -p%mysqlpassword% --databases %mysqlschema% --routines --events --triggers --quick  >%BackupDir%\%mysqlschema%_backup.%datestamp%.sql
 
 
@REM - Housekeeping
forfiles -p %BackupDir% -s -m *.sql -d -%housekeepafter% -c "cmd /c del @path"
pause

Link to comment
Share on other sites

Setup on my in-home server and basically ran your batch file as root no problems?

@REM *** PARAMETERS/VARIABLES ***
SET BackupDir="C:\Users\Administrator\Desktop\Backup_DB"
SET mysqldir="C:\xampp\mysql\bin"
SET mysqlschema=dayz_overpoch
SET mysqlpassword=robio376
SET mysqluser=root
SET housekeepafter=5
 
 
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%% B)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a.%% B)
 
 
set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
set datestamp=%date:~10,4%-%date:~4,2%-%date:~7,2%_%hour%%time:~3,2%
 
 
@REM *** EXECUTION ***
@REM Change to mysqldir
c:
cd %mysqldir%
 
 
@REM dump/backup ALL database, this is all in one line
mysqldump -u %mysqluser% -p%mysqlpassword% --databases %mysqlschema% --routines --events --triggers --quick  >%BackupDir%\%mysqlschema%_backup.%datestamp%.sql
 
 
@REM - Housekeeping
forfiles -p %BackupDir% -s -m *.sql -d -%housekeepafter% -c "cmd /c del @path"
pause

 
 
Right click your db backup folder and make sure it isn't read only and run it again.
PEuazE5.jpg
Link to comment
Share on other sites

ok, I think we're getting somewhere....the folder has a small square in the read only box and says it only applies to files inside.

 

But, when I uncheck that and OK it, it reappears when I check the properties again...

 

I tried creating another folder and exactly the same thing happens...any ideas how I can make that check box clear and stay clear as I'm sure this must be the problem... 

Link to comment
Share on other sites

Here it is....

C:\Users\Administrator\Desktop>SET BackupDir="C:\Users\Administrator\Desktop\Bac
kup_DB"


C:\Users\Administrator\Desktop>SET mysqldir="C:\xampp\mysql\bin"


C:\Users\Administrator\Desktop>SET mysqlschema=Epoch_Database


C:\Users\Administrator\Desktop>SET mysqlpassword=xxxxxx


C:\Users\Administrator\Desktop>SET mysqluser=db_backup


C:\Users\Administrator\Desktop>SET housekeepafter=5


C:\Users\Administrator\Desktop>For /F "tokens=2-4 delims=/ " %a in ('date /t') d
o (set mydate=%c-%a-%b )


C:\Users\Administrator\Desktop>(set mydate=-10-2014 )


C:\Users\Administrator\Desktop>For /F "tokens=1-2 delims=/:" %a in (" 0:04:38.37
") do (set mytime=%a.%b )


C:\Users\Administrator\Desktop>(set mytime= 0.04 )


C:\Users\Administrator\Desktop>set hour= 0


C:\Users\Administrator\Desktop>if " " == " " set hour=00


C:\Users\Administrator\Desktop>set datestamp=-0/-01_0004


C:\Users\Administrator\Desktop>c:


C:\Users\Administrator\Desktop>cd "C:\xampp\mysql\bin"


C:\xampp\mysql\bin>mysqldump -u db_backup -pxxxxxx --databases Epoch_Database --
routines --events --triggers --quick   1>"C:\Users\Administrator\Desktop\Backup_
DB"\Epoch_Database_backup.-0/-01_0004.sql
The system cannot find the path specified.


C:\xampp\mysql\bin>forfiles -p "C:\Users\Administrator\Desktop\Backup_DB" -s -m
*.sql -d -5 -c "cmd /c del @path"
ERROR: No files found with the specified search criteria.


C:\xampp\mysql\bin>pause
Press any key to continue . . .

 

Any thoughts on whether it may have something to do with the read only check box not clearing properly?

Link to comment
Share on other sites

Take a look at the file name of the file that it is trying to write too.

There is a / in the date for some reason.

First thought would be that the server date / time format is different to what is expected.

Try running date /t at a command prompt and paste back the results here.

Seems like the actual date portion is having issues rather than the time part.

Link to comment
Share on other sites

 
C:\Users\Administrator\Desktop>date /t
Sun 10/26/2014
 
C:\Users\Administrator\Desktop>
 
Yep there is a difference.
 
@ReDBaron 
Go to your Regional and Language Options in your windows contol panel and set it to Enlgish (United States) and try your .bat again.
 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...