# cat odoo_backup-to-zos.sh
#!/bin/bash
# 定义本地根目录和远程存储桶前缀
local_root="/data/odoo-storage/"
remote_bucket="zos://xxxxxx-backup/odoo-storage/"
log_file="/var/log/odoo_backup-to-zos.log"
# 脚本执行时间
echo "$(date +'%Y-%m-%d %H:%M:%S') odoo_backup-to-zos Begin" > $log_file
# 日志备份
#zosutil sync /data/logs zos://xxxxxxx-backup/
# 遍历本地根目录下的所有子目录
for dir in "$local_root"*; do
if [ -d "$dir" ]; then
# 检查是否存在 backup 子目录
backup_dir="$dir/backup"
if [ -d "$backup_dir" ]; then
# 获取子目录名称
base_dir=$(basename "$dir")
# 构建远程路径
remote_path="${remote_bucket}${base_dir}/"
# 执行 zosutil sync 命令并记录日志
echo "$(date +'%Y-%m-%d %H:%M:%S') Syncing $backup_dir to $remote_path" >> $log_file
zosutil sync "$backup_dir" "$remote_path" --multipart-chunk-size-mb=128 >> $log_file 2>&1
else
echo "$(date +'%Y-%m-%d %H:%M:%S') No backup directory found in $dir. Skipping..." >> $log_file
fi
fi
done
备份数据上传到对象存储
评论