Manually backup historical data

1:
#!/bin/bash
# screen -L -S mysqldump
DB=zabbix
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_unit | gzip --fast > history_unit.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history | gzip --fast > history.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_str | gzip --fast > history_str.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_text | gzip --fast > history_text.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_log | gzip --fast > history_log.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB trends | gzip --fast > trends.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB trends_unit | gzip --fast > trends_unit.sql.gz
2:
RENAME TABLE history_unit TO history_unit_old;
RENAME TABLE history TO history_old;
RENAME TABLE history_str TO history_str_old;
RENAME TABLE history_text TO history_text_old;
RENAME TABLE history_log TO history_log_old;
RENAME TABLE trends_uint TO trends_uint_old;
RENAME TABLE trends TO trends_old;
3:
#!/bin/bash
# screen -L -S mysqldump
DB=zabbix
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_unit_old | gzip --fast > history_unit_old.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_old | gzip --fast > history_old.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_str_old | gzip --fast > history_str_old.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_text_old | gzip --fast > history_text_old.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB history_log_old | gzip --fast > history_log_old.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB trends_old | gzip --fast > trends_old.sql.gz
time mysqldump --flush-logs --single-transaction --no-create-info $DB trends_unit_old | gzip --fast > trends_unit_old.sql.gz

No comments: