Verification before restore
- Check number of records
- SELECT COUNT(*) FROM zabgate.host_inventory;
- -- 5874 lines
Backup table steps using mysqldump
- 1) Create temporary backup directory (e.g /var/backups/zabgate/mysqldump) and give permission to mysql (ignore if path exist)
- drwxr-xr-x 2 mysql mysql 47 Mar 27 04:39 mysqldump
- 2) Backup table using mysqldump
- Command :
- Single table : mysqldump -uitdba -p db_name table_name > path/table_name.sql
- Multiple table: mysqldump -u root -p dbname table1 table2 table3 > table.sql
- Execution :
- mysqldump -uitdba -p zabgate host_inventory > /var/backups/zabgate/mysqldump/host_inventory_190327.sql
Restore table steps
- 1) Create temp schema/ db
- Mysql > create database temp_backup;
- 2) Move the sql file from mysqldump directory to restore schema and make sure it's executable under mysql
- mv /var/backups/zabgate/mysqldump/host_inventory_190327.sql /seamnt/prd101/mysql/temp_backup/
3) Restore table
- Command :
- mysql -u <user_name> -p db_name
- mysql> source <full_path>/table_name.sql
- Execution:
- mysql > use temp_backup;
- mysql > source host_inventory_190327.sql;
Verification after restore
- Check number of records
- SELECT COUNT(*) FROM temp_backup.host_inventory;
- -- 5874 lines