How to improve automatic MySQL Database Backup command (For linux users) - mysql

Am quite new in server management. Now am struggling to restore one database from whole MySql backup. Currently i have a mysql backup. Am using the following command for backup.
Mysqldump –u root –password={actual password for mysql} –h localhost –all-databases > /backup/mysql_backup.sql
gzip -9 /backup/mysql_backup.sql
I would like to improve this backup, because each back file should be more than 2.5 Gb and restoring is very difficult. If i can't restore from it, then what is the purpose of this backup? So i would like to improve this. Suppose i want to restore a particular database, then its very tedious to find that from this 3Gb file . So i would like to backup each database in a separate file. Any suggestion to improve the above command??

Related

How to backup mysql database every 10 minutes

I want to backup MySQL database every 10 minutes. how i can do it. I don't know how to use procedure or function for it.
I have used
mysqldump -u root -p mydatabase > mydb_backup.sql
I also want to add date and time in end of backup database name. I should only keep latest 3 backup database in system and destroy other database.
How about a backup every second? Well, actually it is "continually". It is called "Replication".
You build another mysql server (machine) as the Slave.
Then copy the data to the Slave, and do CHANGE MASTER on the Slave to have it continually replicate from the Master (which is your current instance of mysql).
AutoMySQLBackup has some great features to:
backup a single database, multiple databases, or all the databases on the server;
each database is saved in a separate file that can be compressed (with gzip or bzip2);
it will rotate the backups and not keep them filling your hard drive (as normal in the daily backup you will have only the last 7 days of backups, the weekly if enabled will have one for each week, etc.).
or you can find more info here 10 Ways to Automatically & Manually Backup MySQL Database
If you are working in unix or linux you can use crontab for scheduling.
To add the the time and date to the backup file you can use a syntax similar to the following
mysqldump -u root -p mydatabase > mydb_backup_`date+"%Y%m%d%H%M%S"`.sql

Fastest way of restoring MYSQL Dump

I have a dump of 2gb size and its taking more than 2 days to restore whole database and still going on.
I am using this command to restore my Database from dump file
mysql -uroot -ppassword new_db < old_db.sql
is there any faster way to do the same. so I can wrap up the Restoration task in one day or less.

MySQL backup procedure for large databases

I currently make a backup of my 2.5GB (and growing) MySQL Database every day. I have over 100 tables that are backed up.
I use this command:
mysqldump --user=user --password=pass --host=localhost db_name | gzip > backup.sql.gz
Works great but when I need to quickly restore data to a single table, it's a horrible process. I have to download the backup, extract the ZIP file, wait forever for the editor to load the SQL file so that I can remove the other tables I don't require. When I need this done fast, I'm pulling my hair out
Can anyone recommend a better way to store MySQL backups? Is there a command to split all the tables into their own sql files?
Appreciate your help!

MySql backup and restoration

Trying to find out how people do a full backup/restore procedure: The user defined database schema and data can be easily backed up via mysqldump, but what about the master tables and data? i.e. if the server goes completely bananas, how can I rebuild the database, i.e. including all the settings in Mysql? is it just a matter of dumping/importing the information_schema and mysql databases + restore my.cnf ? (innodb or MyISAM, not ISAM)
--
edit: Thanks!
You don't back up information_schema, but otherwise, yes, keep a copy of your my.cnf and a dump of the mysql db tables and log settings. To do this do:
mysqldump -u$user -p$pass --all-databases > db_backup.sql
If you're going to restore to the 100% same version of MySQL, you could also backup by shutting down your server and doing a full copy of the contents of /var/lib/mysql (or wherever your data files are) along with your my.cnf file. Then just drop the copy back in place when you want to go live and turn on your server.

How to backup my MySQL's databases on Windows Vista?

How can I backup my MySQL's databases? I'm using Windows Vista and MySQL 5.1.
I have found the folder "C:\Users\All Users\MySQL\MySQL Server 5.1\data" with all my database files and copy them, but how can I restore them if I need?
Thank you.
You could use the mysqldump tool:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
That way you'd get SQL files that you could just execute.
You can also go surf to localhost/phpmyadmin and go to 'export' and select the databases you want to export.
The backup process does not have anything to do with your operating system. Simply export your databases.
You can back up the database files directly, but this can be dangerous if the database is in active use at the time you do the backup. There's no guarantee that you'll make a consistent and valid backup if a query starts modifying on-disk data. You may end up with broken tables.
The safest route is to use mysqldump to output a set of sql statements which can recreate the database completely (table creation + data) in one go. Should you need to restore from backup, you can simply feed this dump file back to mysql:
mysqldump -p -u username nameofdatabase > backup.sql
and restore via:
mysql -p -u username nameofdatabase < backup.sql
The .sql file is just a plaintext dump of all the queries required to rebuild the table(s) and their data.