New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Automatic database backup
thecreator_
Member
in General
Hello, I'm using cyberpanel with a vps and I want to backup the databases of the websites I added to cyberpanel every hour and send them to a safe place. For example, to an email account or other storage.
Is there a method to do this at the server level?
Comments
Hi,
Yes, there are several ways to automatically backup databases on a server, such as using cron jobs or scripts. Here is an example of how to set up a cron job to backup a MySQL database every hour and email the backup file to a specified email address:
Create a backup script that exports the database to a file, for example:
mysqldump -u [username] -p[password] [database_name] > /path/to/backup/file.sql
Use the 'crontab -e' command to open the cron table and add the following line to schedule the script to run every hour:
0 * * * * /path/to/backup/script.sh | mail -s "Database Backup" [email protected]
Save the cron table and the cron job will now run the backup script every hour and email the backup file to the specified email address.
Alternatively, you can use other ways like using a Database management system like Percona Xtrabackup, or a cloud storage service like AWS S3, Azure storage, Google Cloud storage to store the backup files.
Check AutoMySQLBackup: https://github.com/sixhop/AutoMySQLBackup
ElkarBackup is a free open-source backup solution based on RSync/RSnapshot
https://github.com/elkarbackup/elkarbackup
Thank you very much for your help.
Try Veeam maybe, they have free community edition.
If you have other servers you're backing up to, it's built into the engine it self. For example:
https://mariadb.com/kb/en/setting-up-replication/
Configure a master server you need backed up. Create slaves and replicate.
In addition, we can say that many tables are locked during backup and such a backup can put a load on the server, you can increase the interval, or do not backup directly from main db server
Hello, thank you for your reply.
How can I backup from main db server? Does it make sense to use mysqldump with a bash script? So this way, no matter how big the database is, can I correctly backup every hour?
Did anyone tested the ElkarBackup to backup the database 25-30GB size?
There are many ways to backup the Mysql database.
mysqldump via bash script is straight forward way to backup, you have to use it until it does not affect the server's performance/load.
But if you will face issues with high load, you can backup via LVM snapshot or deploy slave DB on another server and make a backup there.