Backing up your database(s) is a very important task, being a sys admin. You have to do this regularly, so the best thing you can do is make it a cronjob to backup at a regular interval. It's very important that you do, because the data it contains is not the kind of data you can retrieve / remake easily without your backups. I will use mysqldump to backup the MySQL databases and save them in text files (.sql), to make them easy to import.

The syntax for using mysqldump to make a database backup to a textfile is the following:

mysqldump --user=root --password="yourpassword" > /home/tim/db_backup.sql


You can see the syntax is very simple. Just call mysqldump with the right credentials and it'll dump the queries needed to restore your database. That dump is easily ported directly to a textfile, so the backup resides there. The textfile makes it easy to transport and import once the database is corrupt.

However, if one database backup won't cut it, and you want to backup all databases at once, you can use the following:

mysqldump --user=root --password="yourpassword" --all-databases > /home/tim/db_backup.sql


Of course you can't use these backups to import everything directly onto your production machine, if you'd really need to. The databases probably still exist, and the backup creates the databases, thus returning an error. Deleting a database manually is fine if you have 1 or 2 databases. In every other case it's just a hassle.

The following contains the solution for this problem. A parameter is added to mysqldump that deletes the database before it's going to restore, with the data in the file:

mysqldump --user=root --password="yourpassword" --all-databases --add-drop-database > /home/tim/db_backup.sql


And then your done, you can now use this to create automatic MySQL backups!



before on Wednesday 11-04-2018

It sounds like you would meet that definition and viagra before pharmacy may be useful for you.

React on this article







Enter the code here: