Jump to content

backup mysql table by cron ?


rugg

Recommended Posts

Hi,

i want to download the two table,

both tblinvoiceitems  and tblinvoices .

what i do now is go to phpmyadmin >> select one table >> export,

and choose CSV with "Put columns names in the first row".

 

i want to ask if any script or command that i can use,

and it can backup as tblinvoiceitems-date-time.csv and store on certain folder,

such as tblinvoiceitems-20180220-112420.csv,

is it possible ?

 

 

thanks alot.

Link to comment
Share on other sites

You can use mysqldump to create an automated cron that will do what you're looking for. Something like this will do what you need. Save this as a cron job outside of your web directory (don't save in public_html), change the variables you need, make sure this is given execute permissions (u+x), and it'll do what you want

#!/bin/sh
myuser="YOUR MYSQL USER"
mypass="YOUR MYSQL PASS"
backupdir="/home/user/backups"
tables_to_dump="TABLES TO DUMP"
database="YOUR MYSQL DB"
timestamp=`date +%m%d%y-%H%M%S`
mysqldump -u$myuser -p$mypass  $database $tables_to_dump >> $backupdir/$timestamp.sql





 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated