outseeker Posted April 4, 2015 Report Share Posted April 4, 2015 MySQL DB backup v1.1. Note: This script is included in the DayZEpoch 1.0.6 distribution (when released). Possible future improvements. Hey Rimblock! Great work producing this- I have been thinking about some kind of automated backup system for some time! :) It's a bit of a departure from what you've done here, but I was wondering if you liked the idea of using database events to make the backup to the database itself instead of, or as well as to a file? ie. event just copies the tables to backup_tablename_date within the same database or similar? Link to comment Share on other sites More sharing options...
Halvhjearne Posted April 4, 2015 Report Share Posted April 4, 2015 i did not see one for linux here, so i thought i would share this i made: #enter db username here DBUSER=myuser #enter db password here DBPASS=mypass #enter path where you want your backups to go DBBACKUPDIR=/path/where/backups/will/end #end user settings DBDIR=$DBBACKUPDIR/$(date +'%A') DBFILE=${1}_$(date +%Y_%d-%m_%H.%M-%S).sql DBNAMEINDIR=$DBDIR/$DBFILE if [ -d $DBDIR ];then echo "Dir $DBDIR already exists" else echo "Creating Dir $DBDIR" mkdir -p "$DBDIR" fi echo "Backing up Database To File $DBDIR/$DBFILE ..." mysqldump --user=$DBUSER --password=$DBPASS $1 > $DBNAMEINDIR #showing old db's #-mmin = +minutes #find ${DBBACKUPDIR} -type f -mmin +240 #-mtime = +days #find ${DBBACKUPDIR} -type f -mtime +2 #deleting older than 3days db's find $DBBACKUPDIR -type f -mtime +3 -delete edit user name, pass, path and save it to a file named something like dbbackup.sh then execute like this: ./dbbackup.sh mydbname Link to comment Share on other sites More sharing options...
sampson42002 Posted November 5, 2015 Report Share Posted November 5, 2015 I have tried this but it's not working. It makes an SQL file with a file size of zero. The connection name is mikes, Im not sure if that is what the mysql user name should be or not. My MySQLWorkbench.exe is installed in this path C:\FTP\MySQL Workbench 6.3.4 CE (win32). I put the mysqldir different because in the path above did not have the MYSQL Server 5.7\bin directory in it. In my hive.ini the database password is blank thats why I did not enter anything in that spot. Here is my bat file.@REM *** PARAMETERS/VARIABLES ***SET BackupDir="C:\FTP\Server Backup"SET mysqldir="C:\Program Files\MySQL\MySQL Server 5.7\bin"SET mysqlschema=dayz_epochSET mysqlpassword=[Enter database password]SET mysqluser=mikesSET housekeepafter=5for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' SET ldt=%%jset datestamp=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2%.%ldt:~8,2%-%ldt:~10,2%-%ldt:~12,2%@REM *** EXECUTION ***@REM Change to mysqldirc:cd %mysqldir%@REM dump/backup ALL database, this is all in one linemysqldump -u %mysqluser% -p%mysqlpassword% --databases %mysqlschema% --routines --events --triggers --quick >%BackupDir%\%mysqlschema%_backup.%datestamp%.sql@REM - Housekeepingforfiles -p %BackupDir% -s -m *.sql -d -%housekeepafter% -c "cmd /c del @path" Someone on the first page had the same problem. They were told to add read at the end. I tried that and it showed more stuff in the command but it closed in 2 seconds or so, so I could not read it. I then added pause under read so I could see what it said. Screenshot of the CMD boxhttp://i950.photobucket.com/albums/ad343/n612ua/backup batch_zpszndn52gg.pngIf someone would please let me know what I did wrong that would be great. Thanks Link to comment Share on other sites More sharing options...
DaveA Posted November 7, 2015 Report Share Posted November 7, 2015 Have a look at this http://stackoverflow.com/questions/20059823/mysqldump-error-1045-access-denied-despite-correct-passwords-etc Looks like the problem possibly may be a windows access problem writing the file. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now