diff --git a/Server Files/Tools/Backup_DB_sample.bat b/Server Files/Tools/Backup_DB_sample.bat new file mode 100644 index 000000000..fcc92c72c --- /dev/null +++ b/Server Files/Tools/Backup_DB_sample.bat @@ -0,0 +1,18 @@ +@REM *** PARAMETERS/VARIABLES *** +SET BackupDir="[Where you want to save the backups]" +SET mysqldir="C:\Program Files\MySQL\MySQL Server 5.6\bin" +SET mysqlschema=[Your DB schema name] +SET mysqlpassword=[your DB password] +SET mysqluser=[your DB user login] +SET housekeepafter=5 +SET datestamp=%date:~-10,2%-%date:~-7,2%-%date:~-4,4%_%time:~0,2%.%time:~3,2%.%time:~6,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% >%BackupDir%\%mysqlschema%_backup.%datestamp%.sql + +@REM - Housekeeping +forfiles -p %BackupDir% -s -m *.sql -d -%housekeepafter% -c "cmd /c del @path" diff --git a/Server Files/Tools/Backup_DB_sample.txt b/Server Files/Tools/Backup_DB_sample.txt new file mode 100644 index 000000000..b1b810cef --- /dev/null +++ b/Server Files/Tools/Backup_DB_sample.txt @@ -0,0 +1,20 @@ +RimBlocks basic MySQL DB backup. + +How to use Backup_DB.bat + +Input your DB connection details and desired backup save location. All details that need changing are in []. Make the changes without the []. + +e.g. +SET mysqlschema=[Your DB schema name] +may change to +SET mysqlschema=EpochDB + +SET BackupDir="[Where you want to save the backups]" +May change to +SET BackupDir="c:\DB-Backups" + +Housekeeping will clear any .sql files that are over housekeepafter number of days old. + +You may need to confirm the MySQL path for the mysqldump exe as it may depend on your provider. + +Add "read" (without "") at the end of the file to require an input for debugging. This allows you to check the test backup is ok and troubleshoot any issues. Remove it when automating or the .bat file will never close. Automation can be done via Windows task scheduler. Create a basic task and then edit the tasks parameters after creating if you want to backup more than once a day. The option is only available after the task is created. \ No newline at end of file