Skip to content

备份 Ceph 指定 bucket 中的文件

设置 ceph-nano 为本地命令

shell
# 寻找当前 eph-nano 安装目录
$ find / -name "cn"
/root/cn
# 移动
$ mv /root/cn /usr/local/bin/
# 检查是否成功
$ cn
Ceph Nano - One step S3 in container with Ceph.

                  *(((((((((((((
                (((((((((((((((((((
              ((((((((*     ,(((((((*
             ((((((             ((((((
            *((((,               ,((((/
            ((((,     ((((((/     *((((
            ((((     (((((((((     ((((
            /(((     (((((((((     ((((
             (((.     (((((((     /(((/
              (((                *((((
              .(((              (((((
         ,(((((((*             /(((
          .(((((  ((( (/  //   (((
                 /(((.  /(((((  /(((((
                        .((((/ (/

Usage:
  cn [command]

Available Commands:
  cluster      Interact with a particular Ceph cluster 
  s3           Interact with a particular S3 object server
  image        Interact with cn's container image(s)
  version      Print the version of cn
  kube         Outputs cn kubernetes template (cn kube > kube-cn.yml)
  update-check Print cn current and latest version number
  flavors      Interact with flavors
  completion   Generates bash completion scripts

Flags:
  -h, --help   help for cn

Use "cn [command] --help" for more information about a command.

下载备份脚本

shell
$  curl -L https://repo.informat.cn/downloads/installer/ceph/ceph_nano_backup_binary.sh -o ceph_nano_backup_binary.sh && chmod +x ceph_nano_backup_binary.sh

配置参数

shell
$ vim ceph_nano_backup_binary.sh

# 修改配置为自己需要的
CLUSTER_NAME="informat-file"               # Ceph集群名
BUCKET_NAME="informat-next"                # 要备份的Bucket
BACKUP_ROOT="/informat/backup/ceph_data"   # 备份根目录
LOG_FILE="/var/log/ceph_backup.log"        # 日志文件
AWS_CLI_PROFILE="ceph-nano"                # AWS CLI配置名称(不需要改)
DATE=$(date +%Y%m%d)                       # 当前日期格式:20240101
AWS_CLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"(不需要改)
AWS_CLI_INSTALL_DIR="/opt/aws-cli"         # 二进制安装目录(不需要改)

设置定时执行

shell
# 编辑系统级用户的 crontab​
$ sudo crontab -e
# 添加定时任务​,在打开的定时任务中添加一行。ceph_nano_backup_binary.sh脚本路径为全路径
0 1 * * * /path/to/ceph_nano_backup_binary.sh
# 验证任务是否添加成功​
$ crontab -l
0 1 * * * /path/to/ceph_nano_backup_binary.sh

0 1 * * * 表示每天凌晨1点执行一次