Open main menu

quick recipe on using mysqldump

Backup

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

mysql $DB < $backup