Showing posts with label archive. Show all posts
Showing posts with label archive. Show all posts

Monday, August 19, 2013

Getting MySQL Backup and Archiving

Hi everyone!

In this article, I am going to show you how to get MySQL backup and archive on Linux. If you use MySQL or any data base, you need backup your database and archive after. So, If you work for huge datas, you get what I mean actually.


I am sure that you heard phpmyadmin before. This is alternative with a user friendly interface for developers. You can import and export datas or all databases. If your size of data is small or medium, phpmyadmin will be perfect for this. But if the size of data increases, phpmyadmin should be doomed. That's why we need console, namely mysqldump! In short if you dont want to get 504 gateway error message, just use it :)

In this regard, let me show you some codes:
$. mysqldump --add-drop-table -h localhost -u username
-p dbname > dbname.sql
$. ls
dbname.sql

The commands given above show us getting dbname database backup and touching dbname.sql file. Using ls command, just listing files in the folder.
$. tar cvzf archive.tar.gz dbname.sql
dbname.sql
$. ls
archive.tar.gz dbname.sql

The commands given above also show us archiving dbname.sql file to archive.tar.gz archive file. After that listing files on there.
Like you have seen up here, we created a archive file. But if want to open it, just do like:
$. tar xvzf archive.tar.gz
dbname.sql

Then we need remove .sql extension file, because it's size may be huge.
$. rm *.sql
$. ls

That's it! What did we do above? We just get the database backup and archive it. After that remove the .sql file. What we've got is my backup archive.
We'll see you next article!