Difference between revisions of "Mysqldump"
Jump to navigation
Jump to search
(Created page with "quick recipe on using mysqldump == Backup == <source lang="bash"> DB=wiki backupdir="$HOME/backups"; if [ ! -d "$backupdir" ]; then mkdir -p $backupdir; fi backup="$backupd...") |
(adds date) |
||
Line 8: | Line 8: | ||
mkdir -p $backupdir; | mkdir -p $backupdir; | ||
fi | fi | ||
− | backup="$backupdir/dump-$(hostname)-$DB.sql"; | + | backup="$backupdir/dump-$(date +%F).$(hostname)-$DB.sql"; |
/usr/bin/mysqldump $DB > $backup; | /usr/bin/mysqldump $DB > $backup; | ||
ls -al $backup; | ls -al $backup; | ||
Line 17: | Line 17: | ||
mysql $DB < $backup | mysql $DB < $backup | ||
</source> | </source> | ||
+ | |||
+ | [[Category:Database]] |
Revision as of 13:18, 26 November 2014
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