一个简单的s3备份脚本

Humus的Python项目详细描述


humus是一个定期将大块数据(如数据库备份)备份到amazon的s3的工具。腐殖质的特性包括:

  • cli工具和python库。
  • 自动文件旋转
  • 自动基于日期的文件修剪。

为什么要使用另一个S3备份工具?

现在的大多数备份工具要么是备份了整个文件目录,要么是没有提供我正在寻找的旋转/修剪工具。

安装和使用

  1. 运行pip install humus

  2. ./humus.ini~/humus.ini/etc/humus.ini/etc/humus/humus.ini处创建如下配置文件:

    [AWS]
    access_key=< YOUR AWS ACCESS KEY >
    secret_key=< YOUR AWS SECRET KEY >
    bucket=some-bucket-name
    
    # Everything after this point is optional
    path=backups
    
    [humus]
    # The number of files to exist in the S3 directory before getting trimmed
    count_limit=2
    # The age in days where files should be trimmed
    age_limit=2
    # The chunk size in bytes for data to be passed to bz2
    chunk_size=1024
    
    # Leave out this section if you want your backup to be unencrypted.
    [encryption]
    gpg_binary=gpg
    encrypt_command=%(gpg_command)s -c --no-use-agent --batch --yes --passphrase %(passphrase)s --cipher-algo AES256 -o %(output_file)s %(input_file)s
    passphrase=< YOUR REALLY LONG ENCRYPTION PASSPHRASE >
    
  3. 每当您想进行新备份时,请运行命令humus my_filename target_fileoutput_cmd | humus my_filename

恢复备份

要恢复备份,只需使用您选择的客户端从s3下载保存的文件。

如果使用上述加密选项,则可以使用以下命令解密备份:

gpg -d --no-use-agent --batch --yes --passphrase < YOUR REALLY LONG ENCRYPTION PASSPHRASE > --cipher-algo AES256 -o my_file.bz2 my_encrypted_file.bz2

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaFX进度条从单独的函数更改而来   jvm使用java服务器选项   java在<li>元素中查找同名的最后一个链接   java问题将参数传递给不同公共类中的构造函数   如何在php中从java函数中获取字符串   java如何在Android中动态显示多个tile   java仅使用Ribbon而不使用任何服务注册表是否可以实现负载平衡?   Jersey 1.19版本的java Swagger JAXRS出现“冲突URI模板”错误   带H2数据库的java Spring boot jpa   从12:00:00到00:00:00的日期转换   Android中的java如何设置文本?   java密钥库“不支持的保护参数”   http使用Java在Java中发送httprequest。净包   SpringJava刷新数据库   java在Spring Boot应用程序中使用嵌入式MongoDb和MongoTemplate失败   java需要什么MatOfMatch对象?   xml使用Java中的合并算法将两个值合并为单个值   java SQLite数据库不保存数据为什么不工作