Page 1 of 1

Backup Database

Posted: 18 Apr 2008, 03:02
by skleung
How can I backup my database?

I just go to mantis/phpmyadmin.php to export the bugtrcaker DB as sql format..is it enough?
So, are all my attachments attached?
And, how about the mantis folder and mysql folder?

Re: Backup Database

Posted: 18 Apr 2008, 15:25
by dialexia
That would depend if the file attachments are uploaded into the database or stored on the hd.

Re: Backup Database

Posted: 03 Nov 2010, 20:14
by partymix
Does anyone have a recommendation / step by step instruction to set up something to automatically back up the database to a diff file location?

I've seen some different things online... but i've attempted them all without success... so any suggestions would be appreciated!

Re: Backup Database

Posted: 04 Nov 2010, 08:55
by istvanb
Actually this is an interesting question since I work on something like that right now.

If you upload your attachments to the database then the proper backup command in your \mysql\bin folder is: mysqldump --user=myusername --password=mypassword --all-databases > MANTIS.SQL

of course if you database is not protected then you wont need a username and a password. At the same time if your database has other thing than Mantis then you should not use the --all-databases switch but you should want to archive only the Bugtracker database.

The restore command is from your \mysql\bin folder: mysql --user=myusername --password=mypassword < MANTIS.SQL

If you store your attachments in a folder then you have to archive that folder as well (pretty much copy the folder to a safe location)


I think this can be done thru the task scheduler of a windows server, but again I am working on this right now. Let me know if you figured out something interesting!

Re: Backup Database

Posted: 04 Nov 2010, 10:45
by istvanb
Our IT is whining about running a script, however they are fine with backing up folders on the server. I think the mantis database can be backed up by copy the \mysql\data\bugtracker folder to a safe location. I am not a database expert but I have found this as an alternative solution on the net and tested manually as well.

Re: Backup Database

Posted: 04 Nov 2010, 11:04
by Phileas
I made a batchfile wich make a SQL Dump described before. This batch runs all night through "planned Tasks" on the Windows Server Maschine.
My IT stores this file (or directory) away on a tape (or similar).
Works fine.

Re: Backup Database

Posted: 04 Nov 2010, 11:13
by istvanb
yeah... that would be the preferred method, if we would have a more helpful IT here :P

Re: Backup Database

Posted: 04 Nov 2010, 12:54
by partymix
Phileas wrote:I made a batchfile wich make a SQL Dump described before. This batch runs all night through "planned Tasks" on the Windows Server Maschine.
My IT stores this file (or directory) away on a tape (or similar).
Works fine.
Would you mind sharing the batchfile you used?

Re: Backup Database

Posted: 04 Nov 2010, 13:13
by istvanb
d:\xampp\mysql\bin\mysqldump --user=rootusername --password=rootpassword --all-databases > d:\backups\fixit.sql

Re: Backup Database

Posted: 04 Nov 2010, 16:22
by partymix
It allows me to backup the entire space... but it wont allow me to simply back up my 'bugtracker' database? Anythoughts? There is 100% a database named bugtracker.

C:\webdev\mysql\bin>mysqldump --password=admin --user=admin --databases=bugtracker > C:\temp\backup.sql
Warning: mysqldump: ignoring option '--databases' due to invalid value 'bugtracker'

Re: Backup Database

Posted: 04 Nov 2010, 16:53
by istvanb
C:\webdev\mysql\bin>mysqldump --password=admin --user=admin bugtracker > C:\temp\backup.sql

Re: Backup Database

Posted: 04 Nov 2010, 17:00
by partymix
thanks man! life saver :D mantis is really cool! I'm diggin it

Re: Backup Database

Posted: 04 Nov 2010, 17:02
by partymix
one last thought- is there anyway to make the logname incorporate datetime stamp are you aware of?

C:\webdev\mysql\bin>mysqldump --password=admin --user=admin bugtracker > C:\temp\backup%date()%.sql

???

Re: Backup Database

Posted: 04 Nov 2010, 17:09
by partymix
Never mind I got it!

For anyone else who wants this.... I figure i'll just set this to run with windows scheduler

file name: backup.bat
---------------------------------------------------------------------------------------
cd C:\webdev\mysql\bin
mysqldump --password=admin --user=admin bugtracker > C:\temp\backup.sql
REN "C:\temp\backup.sql" "* %Date:/= % %Time::=.%.*"
---------------------------------------------------------------------------------------

For example... This creates the file : "backup.sql Thu 11 04 2010 13.53.00.70" located in the C:\temp\ drive.

Re: Backup Database

Posted: 05 Nov 2010, 09:44
by Phileas
You asked for my batchfile. Here is it

Code: Select all

@echo off
set mysqldir="c:\xampp\mysql\bin"
echo Starting Backup of Database: bugtracker

For /f "tokens=1-3 delims=. " %%a in ('date /t') do (set dt=%%c.%%b.%%a)
For /f "tokens=1-4 delims=:." %%a in ('echo %time%') do (set tm=%%a.%%b)
set bkupfilename=bugtracker-%dt%-%tm%.sql
rem echo Backing up to file: %bkupfilename%
%mysqldir%\mysqldump bugtracker -ubackupuser -ppassword > "c:\Backup\%bkupfilename%"
echo Backup Complete!
echo on
So i have a SQL-File with databasename and date-time included.