时间:2015-01-15 16:57:45 作者:qipeng 来源:系统之家 1. 扫描二维码随时看资讯 2. 请使用手机浏览器访问: https://m.xitongzhijia.net/xtjc/20150115/34983.html 手机查看 评论 反馈
# Specify the backup method(s) that will be used.
# tarball: takes a list of directories and builds the corresponding tarballs.
# mysql: archives MySQL databases using mysqldump. To restore the database, you # need to use the same tool manually.
export BM_ARCHIVE_METHOD=“tarball mysql”
# Where to store the backups.
export BM_REPOSITORY_ROOT=“/var/archives”
# The following directive indicates backup-manager to name
# the generated files after the directory that was backed up.
export BM_TARBALL_NAMEFORMAT=“long”
# Define the compression type for the generated files.
export BM_TARBALL_FILETYPE=“tar.gz”
# List the directories that you want to backup.
export BM_TARBALL_DIRECTORIES=“/etc /home /var/log”
# Exclude some subdirectories or file extensions.
export BM_TARBALL_BLACKLIST=“/var/log/myotherapp.log *.mp3 *.mp4”
# List the database(s) that you want to backup, separated by spaces.
export BM_MYSQL_DATABASES=“mysql mybase wordpress dotclear phpbb2”
# MySQL username.
export BM_MYSQL_ADMINLOGIN=“root”
# MySQL password for username.
export BM_MYSQL_ADMINPASS=“mypassword”
# Add support for DROP statements (optional)。
export BM_MYSQL_SAFEDUMPS=“true”
# The hostname or IP address where the database(s) reside.
export BM_MYSQL_HOST=“localhost”
# Port where MySQL server is listening.
export BM_MYSQL_PORT=“3306”
# Compression type (optional)。
export BM_MYSQL_FILETYPE=“gzip”
# Do not archive remote hosts, but only localhost.
BM_TARBALL_OVER_SSH=“false”
# User account for SSH upload.
export BM_UPLOAD_SSH_USER=“root”
# Absolute path of the user‘s private key for passwordless SSH login.
export BM_UPLOAD_SSH_KEY=“/root/.ssh/id_rsa”
# Remote hosts (make sure you have exported your public key to them):
export BM_UPLOAD_SSH_HOSTS=“dev1 dev3”
# Remote destination for uploading backups. If it doesn’t exist,
# this directory will be created automatically the first time
# backup-manager runs.
export BM_UPLOAD_SSH_DESTINATION=“/var/archives/backups/$HOSTNAME”
运行备份管理器
要手动运行备份管理器,请输入以下命令。你也可以选择添加‘-v’标识以便一步一步详细检查运行过程。
# backup-manager
BM_TARBALL_DIRECTORIES列出的目录将作为tarball备份到BM_REPOSITORY_ROOT目录,然后通过SSH传输到BM_UPLOAD_SSH_DESTINATION指定的主机dev1和dev3。
正如你在上面图片中看到的那样,备份管理器在运行的时候创建了一个名为/root/.back-manager_my.cnf的文件,MySQL密码通过BM_MYSQL_ADMINPASS指定。那样,mysqldump可以验证到MySQL服务器,而不必在命令行以明文格式接受密码,那样会有安全风险。
通过cron运行备份管理器
一旦决定哪一天是进行每周备份的最佳日子(最佳时间),你可以让cron来为你运行备份管理器。
打开root的crontab文件(注意,你必须以root登录):
# crontab -e
假定你想要在星期天的上午5:15分运行备份管理器,那么就添加下面这行。
1505**0/usr/sbin/backup-manager 》/dev/null2》&1
小结
上面就是Linux使用backup-manager备份系统的方法介绍了,相对于其他的备份工具,backup-manager更加的简单易用,是系统备份的好帮手。
发表评论
共0条
评论就这些咯,让大家也知道你的独特见解
立即评论以上留言仅代表用户个人观点,不代表系统之家立场