This will remove the backup file for older than 10 days. Create a file using your preferred editor in the /opt location, and add this code to it –įind /home/mysql_backup/*.sql -mtime +10 -exec rm -rf \ Untuk pengguna CPanel, kalian tetap bisa mengikuti arikel ini karena di CPanel pun terdapat menu pengaturan cron job. The following steps will remove the database backup after 10 days from the backup directory –ġ. Pada artikel ini, kami akan mendemonstrasikan cara membuat backup database MySQL mau pun MariaDB secara berkala menggunakan cron job. In that case, you also need to run a script that can remove the backup after a specific period, or it will keep increasing your server disk space. Lets say if I am taking backup of abc database. If you run multiple WordPress websites on your web server like I do, you will need to make regular backups. Suppose you are running a daily database backup. Crontab can be used to schedule the backups for MySQL or MariaDB, Crontab entry consist of six below fields. In this guide, we will walk you through the process of setting up automatic backups for your MySQL or MariaDB databases using cron. usr/bin/mysqldump -u databaseusername databasename -ppassword > /path of database database. Verify the backup in your backup directory to check if the backup is working fine. 1) Cron job to generate database backup in. You should probably write a bash script instead of using PHP. First, you would follow the instructions from this stackoverflow answer to set up the more-secure mysql login method for command line scripts. /dev/null 2>&1 – This will ignore any warning or error received with your cron.Ĥ. First, I recommend you upgrade to mysql 5.6+ so that you can keep your database passwords more secure.Secondly, run the script, make it work well. bin/bash mysqldump -u CENSORED -pCENSORED server gzip > /home/samp/samp03/scriptfiles/sql-backup/databasedate '+d-m-Y'.sql.gz. ![]() ![]() Create a shell script file, named mysql-backup-script.sh. Choose or create a directory where your DB files will be stored. Firstly, you need to make sure that your bash script work well. Change /home/mysql_backup/ - with your exact location of the backup. Steps to create shell script and scheduling using crontab: 1.Change accu_4 – with the actual database name. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |