Difference between revisions of "Mysqldump"

From wikieduonline
Jump to navigation Jump to search
 
(4 intermediate revisions by 2 users not shown)
Line 3: Line 3:
  
 
  [[mysqldump --help]]
 
  [[mysqldump --help]]
 +
[[mysqldump --single-transaction]]
 +
[[mysqldump --skip-lock-tables]]
  
 
== Create backup ==
 
== Create backup ==
Line 12: Line 14:
 
* <code>mysqldump -u root -p --all-databases</code>
 
* <code>mysqldump -u root -p --all-databases</code>
  
* <code>mysqldump -u root -ppassword --flush-logs --delete-master-logs  --all-databases > full-backup.sql</code>
+
* <code>mysqldump -u root -ppassword [[--flush-logs]] [[--delete-master-logs]] [[--all-databases]] > full-backup.sql</code>
  
 
== Restore backup ==
 
== Restore backup ==
Line 26: Line 28:
 
* [[Snapshot]]
 
* [[Snapshot]]
 
* <code>[[--single-transaction]]</code>
 
* <code>[[--single-transaction]]</code>
 +
 +
[[set -o pipefail]]
 +
mysqldump [...] | restic -r /srv/restic-repo backup --stdin
  
 
== Activities ==
 
== Activities ==
Line 31: Line 36:
  
 
== See also ==
 
== See also ==
 +
* {{mysqldump}}
 
* {{MariaDB}}
 
* {{MariaDB}}
 
* {{MySQL}}
 
* {{MySQL}}

Latest revision as of 06:34, 9 June 2024

mysqldump[1] a backup program.

mysqldump --help
mysqldump --single-transaction
mysqldump --skip-lock-tables

Create backup[edit]

  • mysqldump DB_name > DB_name.sql
    • Compressing from stdin
      • mysqldump DB_name | gzip > DB_name.sql.gz
      • mysqldump DB_name | xz -T0 > DB_name.sql.xz
  • mysqldump -u root -p --all-databases

Restore backup[edit]

create database DB_name;
mysql -u root -p DB_name < /path/to/file/DB_name.sql

Related[edit]

set -o pipefail
mysqldump [...] | restic -r /srv/restic-repo backup --stdin

Activities[edit]

See also[edit]

  • https://linux.die.net/man/1/mysqldump
  • Advertising: