Posted By

stiobhart on 06/07/09


Tagged

mysql database db command backup cli


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

orhanveli
JustGreg
umang_nine
dantreacy


mySQL - database backup commands


 / Published in: MySQL
 

CLI commands for backing up mySQL database

  1. -- dump mySQL database to file:
  2. VAR=$(DATE +�%y-%m-%d�); mysqldump -v -uUSERNAME -pPASSWORD -hlocalhost DATABASENAME > /BACKUPDIR/$VAR-DATABASENAME.sql ;
  3.  
  4. -- dump mySQL database to file and then move it:
  5. VAR=$(DATE +�%y-%m-%d�); mysqldump -v -uUSERNAME -pPASSWORD -hlocalhost DATABASENAME > /BACKUPDIR/$VAR-DATABASENAME.sql ; mv /BACKUPDIR/DATABASENAME.sql /OTHERBACKUPDIR/$VAR-DATABASENAME.sql ;

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: stiobhart on October 11, 2009

apologies for the fuck-up with the date syntax. dunno why this has happened - aren't we all using unicode here?

you can ignore the 'VAR=$(date....) ' and '$VAR' stuff if you want. it's only there to add the backup date to the filename, when it saves the DB dump.

You need to login to post a comment.