• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[MySQL] How to backup your database in a variety of ways!

Skylinx

Game Programmer
Joined
Nov 26, 2008
Messages
399
Reaction score
14
Location
TORONTO, CANADA
I have seen people asking questions on how to backup MySQL databases.
I will show you my ways, and other suggested ways.

1) MySQL AutoSQLBackup
http://sourceforge.net/project/show...] - SourceForge.net: AutoMySQLBackup Download
Functions: it backs up 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.).

How to Install?
The installation is very simple: just download the one file bash script and save it somewhere, customize it to fit your setup (only some basic changes are needed: like the MySQL user and password, backup location), make it executable and activate it in cron as needed (daily for example).
Within the bash, there should be

Code:
# Username to access the MySQL server e.g. dbuser
USERNAME=dbuser

# Username to access the MySQL server e.g. password
PASSWORD=password

# Host name (or IP address) of MySQL server e.g localhost
DBHOST=localhost

# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
DBNAMES="DB1 DB2 DB3"

# Backup directory location e.g /backups
BACKUPDIR="/backups"

# Mail setup
# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and sql files as attachments (see docs)
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
MAILCONTENT="stdout"

# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])
MAXATTSIZE="4000"

# Email Address to send mail to? ([email protected])
MAILADDR="[email protected]"
Edit those to what you want.


[If above was to complicated for you .. and you want an easier way.]


2) Navicat for MySQL
First download Navicat
Navicat - Download Center - Download the World's Best Oracle Manager, MySQL Front End & PostgreSQL GUI for Windows, Linux & Mac OS X - Download Now! Support Access to MySQL, Excel to MySQL, MySQL editor, MySQL administrator, MySQL frontend, MySQL man
Then login to your MySQL.
From there you make a new database.
Open your old one, and select all the tables, and just drag them into the new schema.
It should completely copy every piece of data into the backup database ..
This is probably the easiest method of backing up .. but it is the most primitive and manual.

3) MySQL Dump (If you don't know how to execute the following commands .. then you should learn more about MySQL)
You can use mysqldump to create a simple backup of your database using the following syntax:

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

What do these do?
-mysqldump (The command param)
-[username] Place your mysql username here
-[password] Place your mysql password here
-[database] Place the name of the database you wish to backup
-[backupfile.sql]The name of the backup sql file you wish to have!

After you've executed that syntax into the console .. and you wish to re-execute the database if god forbid something happen to yours. Then just execute that .sql file you backed up! And your all good!

I'll be updating more methods after!
Maybe adding pictures!
If this helped you, rep me :)
 
Last edited:
Back
Top