How to backup mysql database while application is running? - mysql

What is the prefer way to generate mysql backup while application is running ?
I want to provide functionality to admin to take backup of database at the same time when other admin using the same application from other computer.
What is the prefer way to handling this scenario ?

Hopefully you can take backup using mysqldump utility without stopping the database. Mysqlworkbench application provides easier interface to do this. If you are looking for a more advanced option and worry about transaction you can set up a replicated server, so that you can take the stable backups without stopping the master server.

if you are working on a webserver with php support use phpMyAdmin or any mySQL Dumper

Related

Saving all local MySQL operations to replicate them to an online database

I have two databases right now: one in local and one in the cloud.
I was wondering if it would be possible to save all the MySQL DML commands/operations that I perform in my local database somewhere (e.g. local file system, or even a new separate table for it in the database) so I can then process all of those commands, one by one and replicate them to my database in the cloud?
The reason is that I'm using my database in the cloud as the backup database and so my local database and my online database should be in sync.
If what I'm thinking isn't possible, is there another way around this?
Thank you very much!
Replication or Use canal may solve your problem
Yes, there is such a feature. It's called the Binary Log. There's no need to explain further, because it has full documentation. Visit the link I just provided.
It's probably not easy to use replication in your case, because it would require your remote MySQL Server to connect to your local MySQL as a client, and I expect that's not possible because of firewalls or NAT.
But you could collect your local binary logs, and upload them periodically, and then use the same technique as point-in-time recovery to apply them to the remote MySQL server. See https://dev.mysql.com/doc/refman/8.0/en/point-in-time-recovery-binlog.html

What is a clean and simple method of backing up Ruby on Rails app and MySQL database?

I started learning Ruby and Rails over the past week or so. I have completely destroyed my app and had to redo everything a couple of times. haha
It is a giant pain rebuilding everything using only a backup folder of some copied files. I'm sure I'll break some more stuff in the future.
Are there any good gems or tools that will help me backup both the App and the MySQL database?
I have used this option for MySQL but it doesn't seem to work well when working with Rails:
mysqldump database_name > database_name.sql
First of all: you don't need to do backup of your application. You should use version control system (git, for example) and automated deployment (capistrano, chef or whatever). Using this two principles you can always redeploy your application on the broken VPS or transfer it to another server.
Then, about DB backup - just do it using your DB abilities (mysqldump in your case) :) You can set up, for example, CRON task, which will backup your database once a day. But don't forget that it will be much better if you will store your dump on the other server - in case of your server being completely broken.

How do I migrate a SQLAnywhere 9 db running in a remote server into a mysql server on my machine?

I am working at a company that has some CRM software running in a remote Windows XP server that uses a SQLAnywhere 9 db to store its data; I have access to this remote server with an administrator account.
I would like to extract the db into a .sql file so that I can run the db locally on my machine without affecting the running db in the server (since it is key for the company's day to day operation).
The reason I need this is that we are going to test some BI Software and we need data from this database to test it, but we don't know the structure of the database since the developers of the CRM software didn't give us any documentation on it. So we need to have the database locally so that, without affecting the running CRM, we can:
understand the structure by looking at the DDL
make queries to it to get sample data
I researched a bit, and the most common solution to my problem was to use dbunload on the remote server to unload the db into a reload.sql file that contained what I needed. But most tutorials on the subject mention that I have to stop the db first (which would be catastrophic). If this is the only option, then I guess I am willing to do it on the weekend when the CRM is not used, but I wanted to know if there was another solution first.
If there is no other solution, can you point me to where I can find the proper and safer way to do this?
I have researched a lot, but prior to this day I have never even heard of SQLAnywhere, so I really need all the help I can get. My main concern is doing something that impacts negatively the CRM software.
Thank you.
You can run dbunload across the network, you just have to tell it to do an "external" unload. The default is to do an internal unload which would only work from the machine where the database server is running.
I don't have SQL Anywhere 9 documentation right now to look up the exact switch, but dbunload -? should show you all the possible switches.
Edit:
-an will create a new database and load the data and schema from another data
-xi switch will do external unload and internal reload.
-c parameters to connect to your remote database

Back up MySQL using phpMyAdmin

I have used MySQL for my application written by PHP. After a time its data will be great and I need to make a backup from them. Also, I need I can restore the backup data whenever I need. My question is if phpMyAdmin can make backup and resotore it secure and completely without any data lose?
(I have both MyISAM and innoDB in my database structore)
Also, if you know any other IDE to make backup and restore it without showing the database structures and tables to the end-user, please tell me their names.
Thank you.
If you're running MySQL on your own server you may copy the database folder, but the MySQL server would have to be stopped first. Anyway I'd recommend dumping the databases through phpMyAdmin (export function) or via the command line (mysqldump). Using the latter, you may write a batch script that also compresses and encrypts the content of the dump file.
Using the built in Import and Export? The only data loss would be everything after the backup until the time the backup was imported.
Securely? That's an entirely different topic. There's too many things to consider to call anything secure but if you're using https or on a trusted LAN, then yes, I guess it's secure.
I think MySQL Workbench can do exports and imports.
If would you wish to backup MySQL database more securely and periodically without loss of data to remote server or local drive (local hard disk or mapped drive), then you can try Vembu StoreGrid http://www.vembu.com/, a leading backup software trusted by more than 2700 service providers world wide. Once you configured single backup by selecting entire database then automatically newly added database will be backedup on upon next backup time. Also, StoreGrid backups only the incremental bytes of changes on next incremental schedule.
Vembu has a solution for almost everyone, just check them below:
For Service Providers : StoreGrid Service Provider Edition
For Business/Offices : StoreGrid Professional Edition
For Home Users: Vembu Home
For Resellers who don't want to have their own storage : Vembu Pro
For Hosting Providers: StoreGrid Hosting Provider Edition (yet to be released)
For your requirement, we would suggest the Professional Edition http://storegrid.vembu.com/online-backup/network-backup.php of StoreGrid. Try it!!!
Regards,
Thileepan
vembu.com

Remote backup of MySQL database

Our Java server application logs data to a SQL database, which may or may not be on the same machine. Currently we use MS SQL Server, and we're now porting to MySQL. A user configures database backup parameters on our app server, e.g. time of day to run a backup, and the app server executes SQL Server's BACKUP DATABASE command at the appropriate time, via a sproc. It does incremental backups daily and full backups weekly.
MySQL lacks an equivalent feature to tell the database from a client connection to back itself up. Options we're considering are:
Create a UDF to shell out to mysqldump (or copy database files), which can be called from our app server via a sproc. Essentially we'd be implementing a version of BACKUP DATABASE for MySQL.
Create a service to run on the MySQL box that can get the backup settings from the app server and run mysqldump (or file copy) locally.
Create a backup sproc to mimic mysqldump, e.g. SHOW CREATE TABLES and SELECT INTO OUTFILE for each table.
Setting up a cron job, Perl script, third-party app or other tricks that'd work great in a data center aren't preferred; this is a shrink-wrap package that needs to be pretty robust and hands off.
Database sizes can range from roughly 10MB to 10GB.
I'm aware of the binary logs for the incremental piece. I figure the general solution will probably apply to them as well, if we decide to use them.
This is all on Windows 2003 32-bit or 2008R2 64-bit, MySQL 5.1.
The UDF option seems the best to me. The UDF Repository (http://www.mysqludf.org/) has mysqludf_sys, which may be all we need, but I thought I'd ask for opinions since after extensive googling it doesn't seem like others have reached the same conclusion, or maybe our needs are just out of the ordinary. Our app is the only thing in MySQL, so I'm not worried about other users having access to our UDF.
Any solutions I'm overlooking? Any experience with using UDFs in such a way?
Thanks,
Eric
For this an other reasons we decided to collocate our application with the database, so this problem became moot.