控制节点备份:
备份openstack的mysql数据库并拷贝到192.168.8.66:/opt/backup/openstack_mysql/目录:
vim /backup/shell/backupmysql.sh
#!/bin/bash
backup_dir="/backup/mysql"
filename="${backup_dir}/mysql-`hostname`-`eval date +%Y%m%d`.sql.gz"
# Dump the entire MySQL database
/usr/bin/mysqldump --opt --all-databases | gzip > $filename
scp $filename 192.168.8.66:/opt/backup/openstack_mysql/
# Delete backups older than 7 days
find $backup_dir -ctime +7 -type f -delete
加入定时程序:
crontab -e
0 0 * * * /backup/shell/backupmysql.sh &>/dev/null
(注意,scp需要建立信任关系,在目的主机的authorized_keys中加入源主机的id_rsa_pub验证码)
备份openstack的/etc目录:
vim /backup/shell/backup_etc.sh
#!/bin/bash
backup_dir="/backup/etc"
filename="${backup_dir}/etc-`hostname`-`eval date +%Y%m%d`.gz"
# Dump the entire MySQL database
tar czf $filename /etc
scp $filename 192.168.8.66:/opt/backup/openstack_files/
# Delete backups older than 7 days
find $backup_dir -ctime +7 -type f -delete