通过xtrabackup工具对mysql数据库做全备
需求描述:
使用xtrabackup工具对mysql实例中的所有的数据库进行备份,并且将备份的过程输出到指定的日志文件中.
操作过程:
1.使用xtrabacup工具备份mysql实例
xtrabackup --backup -uroot -pmysql \ --target-dir=/home/mysql/workspace/mysql_backup/FullBackup/Full_Backup_2018-04-19 \ 2>/home/mysql/workspace/mysql_backup/FullBackup/Full_Backup_2018-04-19.log
备注:xtrabackup执行过程的内容会输出到STDERR,所以,直接使用>即STDOUT是不能将输出重定向到文件的.--target-dir指定了要将备份写到哪个目录下,--backup就是对mysql实例做备份
2.查看生成的备份文件及日志
[mysql@redhat6 FullBackup]$ ll total 176 drwxr-x--- 17 mysql mysql 4096 Apr 18 19:03 Full_Backup_2018-04-19 -rw-rw-r-- 1 mysql mysql 175655 Apr 18 19:03 Full_Backup_2018-04-19.log #备份日志中是有内容的. [mysql@redhat6 FullBackup]$ pwd /home/mysql/workspace/mysql_backup/FullBackup
查看日志:
-rw-rw-r-- 1 mysql mysql 175655 Apr 18 19:03 Full_Backup_2018-04-19.log [mysql@redhat6 FullBackup]$ pwd /home/mysql/workspace/mysql_backup/FullBackup [mysql@redhat6 FullBackup]$ more Full_Backup_2018-04-19.log 180418 19:02:15 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/tmp/mysql.sock' as 'root' (using password: YES). 180418 19:02:15 version_check Connected to MySQL server 180418 19:02:15 version_check Executing a version check against the server... 180418 19:02:15 version_check Done. 180418 19:02:15 Connecting to MySQL server host: localhost, user: root, password: set, port: 3306, socket: /tmp/mysql.sock Using server version 5.5.57-log xtrabackup version 2.4.10 based on MySQL server 5.7.19 Linux (x86_64) (revision id: 3198bce) xtrabackup: uses posix_fadvise(). xtrabackup: cd to /mysql/data xtrabackup: open files limit requested 0, set to 65536 xtrabackup: using the following InnoDB configuration: xtrabackup: innodb_data_home_dir = . xtrabackup: innodb_data_file_path = ibdata1:100M:autoextend xtrabackup: innodb_log_group_home_dir = /mysql/data/ xtrabackup: innodb_log_files_in_group = 2 xtrabackup: innodb_log_file_size = 5242880 InnoDB: Number of pools: 1 180418 19:02:15 >> log scanned up to (2169910173) xtrabackup: Generating a list of tablespaces InnoDB: Allocated tablespace ID 1077 for employees/employees, old maximum was 0 180418 19:02:16 >> log scanned up to (2169910173) 180418 19:02:17 >> log scanned up to (2169910173) 180418 19:02:18 >> log scanned up to (2169910173) 180418 19:02:19 >> log scanned up to (2169910173) 180418 19:02:20 >> log scanned up to (2169910173) 180418 19:02:20 [01] Copying ./ibdata1 to /home/mysql/workspace/mysql_backup/FullBackup/Full_Backup_2018-04-19/ibdata1 180418 19:02:21 >> log scanned up to (2169910173) 180418 19:02:22 >> log scanned up to (2169910173) 180418 19:02:23 >> log scanned up to (2169910173) 180418 19:02:24 >> log scanned up to (2169910173) 180418 19:02:25 >> log scanned up to (2169910173) 180418 19:02:26 >> log scanned up to (2169910173) 180418 19:02:27 >> log scanned up to (2169910173) 180418 19:02:28 >> log scanned up to (2169910173) 180418 19:02:29 >> log scanned up to (2169910173) 180418 19:02:30 >> log scanned up to (2169910173) 180418 19:02:31 >> log scanned up to (2169910173) 180418 19:02:32 >> log scanned up to (2169910173)
备注:说明全备份没有问题,并且也产生了日志文件.
文档创建时间:2018年4月19日11:46:14