HOW TO: Backup your MySQL database

The easiest way to automatically backup your database is with a simple cron job running the following command ever few hours or at least daily:
mysqldump -hLOCALHOST -uDBUSERNAME -pDBPASSWORD DATABASE | gzip > /FOLDER/TO/BACKUP/DATABASE.sql.gz

Change the following to your server's settings:
LOCALHOST - Normally this will be localhost but if you have an external MySQL server this may be different.
DBUSERNAME - Change this to your database username (for security, we recommend that you create a new username just for running backups with reduced permissions).
DBPASSWORD - Change this to your database password.
DATABASE - Replace with the name of your database.
/FOLDER/TO/BACKUP/DATABASE - Change this to the directory you want your backup to be saved too and set the file name to something recognizable (such as the database name), also do not forget to keep the .sql.gz since it is being compressed by gzip and it is easier to restore with the correct filename.

If you have any questions please feel free to contact us and we will be happy to assist with your backup needs.

  • 21 brukere syntes dette svaret var til hjelp
Var dette svaret til hjelp?

Relaterte artikler

HOW TO: Backing up files with 1 line of code

rsync -avz /my/folder/ user@SERVERIP:/home/user/my/folderYup, that's it. All you do is enter the...

HOW TO: Cancel your service

Login to the Client Area. Click on "My Services" under the "Services" tab at the top. Click...

HOW TO: Creating an SSH RSA Key with PuTTYgen.exe

1) Open PuTTYgen.exe set the type to SSH2 RSA and minimum 1024 bits.2) Click "Generate" and move...

HOW TO: Automatically backup your user data with rsync

Here is a quick and easy way to backup your files and MySQL database with a simple script:...

HOW TO: Setup a very basic Debian VNC server (XFCE4 Desktop)

For those of you who are interested in adding a GUI to your server that you can connect remotely...