Difference between revisions of "Mysqldump"
Jump to navigation
Jump to search
(add single-transaction switch) |
(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...") |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | quick recipe on using mysqldump | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | == Backup == | |
− | |||
<source lang="bash"> | <source lang="bash"> | ||
− | + | DB=wiki | |
− | + | backupdir="$HOME/backups"; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | backupdir="/backups"; | ||
if [ ! -d "$backupdir" ]; then | if [ ! -d "$backupdir" ]; then | ||
− | mkdir -p | + | mkdir -p $backupdir; |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
fi | fi | ||
− | + | backup="$backupdir/dump-$(hostname)-$DB.sql"; | |
− | + | /usr/bin/mysqldump $DB > $backup; | |
− | + | ls -al $backup; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
Line 93: | Line 17: | ||
mysql $DB < $backup | mysql $DB < $backup | ||
</source> | </source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 11:41, 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-$(hostname)-$DB.sql";
/usr/bin/mysqldump $DB > $backup;
ls -al $backup;
Restore[edit | edit source]
mysql $DB < $backup