This page describes how to backup data from existing installation of MySQL or MariaDB. Backup documentation is available at [1].
Backup using mysqldump
The purpose of this backup is to create a text file with SQL commands, that will be used to re-create content of all databases eventually.
Upstream documentation for using mysqldump
is available at [2].
Prerequisites
- running MySQL/MariaDB server
- read access to all databases you need to backup -- usually done using root account
Dumping all databases
shell> mysqldump --all-databases > "dump-`date +%y%m%d%H%M%S`.sql"
Expected results
Content of the database is stored in SQL form in the specified file.
Backup using copying binary files of data stack
Upstream documentation for performing backup of database using copying files is available at [3].
Prerequisites
- stopped MySQL/MariaDB server or (in case you cannot stop the server) locked and flushed tables (see upstream documentation above)
- read access to database files, which are by default located under /var/lib/mysql
Copying database files
shell> cp -r /var/lib/mysql/ "/safe/backup/mysql-backup-`date +%y%m%d%H%M%S`"
Expected results
Content of the directory /var/lib/mysql/ is copied into the specified location.