I have a Ubuntu server with a Mysql daatabase.
I would like to set up an automatic backup of this database during the night on another server (ovh for example).
I don't know what would be the best tool for that.
If someone has some advices…
Thanks in advance.
Best Answer
The easiest way to automate this task would be the combination of MySQL Dumps and a cronjob. You can find a lot of information on this topic on this and other internet sites, but for the sake of completion:
Create a mysqldump.sh file
Which will contain the mysql dump command we will schedule in a cron job (replace user, password and path to match your environment):
Edit: If you want the script to store the backup in a remote location, just mount the corresponding device or share and use the mount path in the script.
Test the script
Ensure that the script has execution permissions:
Execute the script:
And test it is working correctly (The backup file will be created in the specified backup folder).
Create and schedule a new cron job
In a command prompt type
And add the following line at the bottom of the file:
This will execute the script every day at 23:30.
Extend this simple script
There is literally loads of things you can do in order to improve this simple backup method:
So do not end here and experiment! :-)
Use backup-tools or cloud-based backup-services
Although the above method is one of the easiest and can be extended to suit your specific needs, it is worth mentioning that there are other alternatives:
Please bare in mind that I'm not related in any way to any of the above mentioned solutions and services and I'm listing them only for reference, so use them at you own risk.