Last active
April 24, 2017 09:36
-
-
Save sarkarshuvojit/1dfc6dd2016426372f11017201707261 to your computer and use it in GitHub Desktop.
Cron job to backup the database everynight.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mysqldump] | |
user=root | |
password=somepass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make sure to have a folder ~/db_backup | |
# and also a .my.cnf in your home folder containing your mysql username and password | |
$backup_file = "$dbname" . date("Y-m-d-H-i-s") . '.sql'; | |
$command = "mysqldump -u $dbuser $dbname > ~/db_backup/$backup_file"; | |
system($command); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment