Frivole.com Project: Backup of mySQL databases

August 10, 2006 – 8:31 am

I recently wrote about my client with the Frivole.com project has been having some issues with data loss because someone appears to hacking into the databases and corrupting them.

After repeated attempts contacting the Hosting company, they say “it isn’t us” and i know that it is not me or the client causing this because of the limited access we have on the project. This morning my client changed the passwords and usernames which is the first good step in protecting yourself from an attack like this. Naturally the other good step is to backup up your databases in case of attack.

I found a good article on Devshed for database backups in mySQL and just thought i would share a sampling of that. Its just a way to simply backup a database by dumping the contents of the database into a file but it gets the job done…

You can use mysqldump to create a simple backup of your database using the following syntax.

mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]

    • [username] - this is your database username
    • [password] - this is the password for your database
    • [databasename] - the name of your database
    • [backupfile.sql] - the file to which the backup should be written.

    The resultant dump file will contain all the SQL statements needed to create the table and populate the table in a new database server. To backup your database ‘Customers’ with the username ’sadmin’ and password ‘pass21′ to a file custback.sql, you would issue the command:

    mysqldump -u sadmin -p pass21 Customers > custback.sql

    You can also ask mysqldump to add a drop table command before every create command by using the option –add-drop-table. This option is useful if you would like to create a backup file which can rewrite an existing database without having to delete the older database manually first.

    mysqldump –add-drop-table -u sadmin -p pass21 Customers > custback.sql

    Source: http://www.devshed.com/c/a/MySQL/Backing-up-and-restoring-your-MySQL-Database/

    If you go on to read the full article it expands how to how more specific data backups and how to restore them. Very handy article indeed!

    Lucas

    Do you know where your data is?

Post a Comment