因业务需要对一些附件及数据进行冷备份,原服务器上有打包备份,直接在备份脚本中增加上传至ucloud的归档备份即可,
工具各版本下载地址及说明:https://docs.ucloud.cn/storage_cdn/uarchive/quick
这里用的是Linux版本直接命令行操作即可:
下载、解压、安装:

wget http://tools.ufile.ucloud.cn/uarchivemgr-linux64.tar.gz
tar xvf uarchivemgr-linux64.tar.gz
mv uarchivemgr_linux64.elf/ /usr/local/ubak
mv /usr/local/ubak/uarchivemgr-linux64 /usr/local/ubak/uarchivemgr
chmod +x /usr/local/ubak/uarchivemgr-linux64
mkdir /usr/local/ubak/log

查看能否运行:/usr/local/ubak/uarchivemgr help查看帮助

[root@rh7166]# /usr/local/ubak/uarchivemgr help
uarchivemgr is a tool for manage uarchive.
Usage:

    uarchivemgr --config conf_path command [arguments]
        --config is to specify config path and is optional, if not specified use config.cfg in working dir
The commands are:
    version              print uarchivemgr version
    GetArchiveList       get all the archives within one archive
    DeleteVault          delete specified vault
    DescribeVault        Describe vault info according to specified vaultname or list vaults under account
    CreateVault          create public or private vault
    DeleteArchive        delete one archive in the specified vault
    ActivateArchive      activate an archive within one vault
    DownloadArchive      download an archive within one vault
    PutArchive           upload local files to specified vault
    MputArchive          sharding upload local files to specified vault
    Sync                 sync the modified files of specified dir to specified vault
    ETag                 calculate etag of local files

Use "uarchivemgr help [command]" for more information about a command

修改/usr/local/ubak/config.cfg,在public_key和private_key处,填上你账号的API秘钥即可

{
    "public_key": "",
    "private_key": "",
    "api_host" : "api.spark.ucloud.cn",
    "proxy_host" : "www.uarchive.ucloud.cn",
    "port" : 80
}

使用方法介绍

上传文件:
/usr/local/ubak/uarchivemgr MputArchive -vault bj2-file-bak -archive bright_fastdfs_20170927230.tar.gz -file /data/upload_bak/bright_fastdfs_20170927230.tar.gz

上传目录:
/usr/local/ubak/uarchivemgr MputArchive -vault bj2-file-bak -dir /data/upload_bak

激活文件:
/usr/local/ubak/uarchivemgr ActivateArchive -vault bj2-file-bak -archive bright_fastdfs_20170927230.tar.gz

下载文件:
/usr/local/ubak/uarchivemgr DownloadArchive -vault bj2-file-bak -archive bright_fastdfs_20170927230.tar.gz -saveas  /tmp/bright_fastdfs_20170927230.tar.gz

删除文件:
/usr/local/ubak/uarchivemgr DeleteArchive -vault bj2-file-bak -archive bright_fastdfs_20170927230.tar.gz

获取列表:
/usr/local/ubak/uarchivemgr GetArchiveList -vault bj2-file-bak

计算Hash值:
/usr/local/ubak/uarchivemgr -config /usr/local/ubak/config.cfg ETag -file /data/upload_bak/bright_fastdfs_20170927230.tar.gz

附MySQL备份、上传脚本:

#!/bin/sh
date=`date "+%Y%m%d%H%M%S"`
back_path=/data/mysql/backup/data
mkdir -p $back_path
mysqldump=/usr/local/mysql/bin/mysqldump
cd ${back_path}
${mysqldump} -uroot --password="xxxxx"  -R -E -h localhost --skip-opt --socket=/usr/local/mysql/mysql.sock --single-transaction --flush-logs --master-data=2 --add-drop-table --create-options --quick --extended-insert=false --set-charset --disable-keys  --all-databases |gzip > bright_dbs.${date}.sql.gz
xm=bright
f=${xm}_dbs.${date}.sql.gz
d=/usr/local/ubak
cd $d
$d/uarchivemgr -config $d/config.cfg MputArchive -vault bj2-file-bak -archive $f -file $back_path/$f >> $d/log/$f.log 
$d/uarchivemgr -config $d/config.cfg GetArchiveList -vault bj2-file-bak  | grep $xm >> $d/log/$f.log
localfile=`"$d"/uarchivemgr -config "$d"/config.cfg ETag -file "$back_path"/"$f" >> "$d"/log/"$f".log`
remotelyfile=`"$d"/uarchivemgr -config "$d"/config.cfg GetArchiveList -vault bj2-file-bak | grep "$localfile"`
if [[ $remotelyfile =~ $localfile  ]]
then
echo "Hash ok,backup success" >> $d/log/$f.log
else
echo "Hash error" >> $d/log/$f.log 
fi

几点说明:

-vault 存储空间名称
-archive 归档存储文件名
下载文件的时候要先激活,然后在下载,
-saveas 下载保存的文件名可以用原来的也可以自定义;
上传文件或目录最好用MputArchive,支持分片、断点续传,问题少。
Tags标签: 归档,ucloud,冷存储 Tags相关文章如下:

上一篇:阴雨绵绵

下一篇:MongoDB主从复制设置