Mysqldump

From Freephile Wiki
Revision as of 13:18, 26 November 2014 by Freephile (talk | contribs) (adds date)

Jump to navigation Jump to search

quick recipe on using mysqldump

Backup[edit | edit source]

DB=wiki
backupdir="$HOME/backups";
if [ ! -d "$backupdir" ]; then
  mkdir -p $backupdir;
fi
backup="$backupdir/dump-$(date +%F).$(hostname)-$DB.sql";
/usr/bin/mysqldump $DB > $backup;
ls -al $backup;

Restore[edit | edit source]

mysql $DB < $backup