alkpone 1000000 Report post Posted September 11, 2013 Hey, if anybody knows how to write a CRON table script able to first save some folder and some mysql databases in an archive daily, feel free to help here or in pm. I though that it would be a good idea to make some automatic backups of site and database. And indeed I didn't made any linux script for years and help would be greatly appreciated. Quote Share this post Link to post Share on other sites
PerfectMiscreation 0 Report post Posted September 11, 2013 I havent played with Linux in a long time, but here is a link I used for database back up, it may help. If not, my apologies for the waste of time Hope this helps Quote Share this post Link to post Share on other sites
username1001101 11 Report post Posted September 13, 2013 Something like this - didn't test it though #!/bin/bash # Set Paths orig="/path/to/data/folder" bu="/path/to/backup/folder/" # Set MySQL info user="mysqluser" password="mysqlpassword" host="localhost" dbname="dbname" options="-Q -c -C --add-drop-table --add-locks --quick --lock-tables" # Set current timestamp now="$(date '+%Y-%m-%d_%H:%M')" # Go to original folder cd "${orig}" # Make MySQL dump mysqldump -u${user} -p${password} -h{$host} "${options}" "${dbname}" > "backup.sql" # Go to backup location cd "${bu}" # Make backup tar cvfz "backup_${now}.tgz" "${orig}" # Delete mysql backup file rm "${orig}/backup.sql" cron entry: 0 3 * * * bash "/path/to/backup_script.sh" >> /dev/null 2>&1 Quote Share this post Link to post Share on other sites
alkpone 1000000 Report post Posted September 13, 2013 Sweeet, thx !! Quote Share this post Link to post Share on other sites
username1001101 11 Report post Posted September 13, 2013 As said, it's not tested but it should work.... Quote Share this post Link to post Share on other sites