使用简单的toml文件将生产服务器的duplicity备份到s3。
duplicity-backup-s3的Python项目详细描述
复制备份到S3
使用简单的toml文件将生产服务器的Duplicity备份到S3
许可证
免费软件:apache软件许可证2.0
功能
这是一个duplicity命令行备份包装器,它将使用一个经过验证的yaml配置文件,使用现代而出色的cli模式备份到s3。实现了命令incremental
、list files
、status
、verify
、cleanup
和remove
。
为duplicity构建这个(又是另一个)cli包装的主要用例是能够在生产环境中部署命令并将其注入到cron.daily
中,并对生产服务器进行自动备份。我们使用它来实现生产服务器备份的自动化
依赖关系
duplicity
python-boto
连接到s3
安装
您可以将其作为系统命令安装到任何支持Python3.5或更高版本的操作系统上。
要从PyPI安装为全局命令,请执行以下操作:
python3 -m pip install duplicity-backup-s3
仅从pypi为用户安装
python3 -m pip install --user duplicity-backup-s3
从git存储库(最新的主分支)安装:
python3 -m pip install git+https://github.com/jberends/duplicity_backup.git#wheel=duplicity_backup_s3
首次使用
首先,您需要创建一个配置yaml文件您可以为此使用helper命令init
。使用内置的帮助功能,让您尽情享受。
# help is neigh duplicity_backup_s3 --help # and to init the configuration YAML file duplicity_backup_s3 init
它将把一个duplcitiy_backyp_s3.yaml
放到当前目录中。会是这样的:
aws:AWS_ACCESS_KEY_ID:foobar_aws_key_id# your amazon S3 user that has write right to a backup bucketAWS_SECRET_ACCESS_KEY:foobar_aws_access_key# your amazon S3 user secretbackuproot:/home# the backup 'root' path. Everything underneath is considered for backup.excludes:-"**"# a list of exclude paths. May be '**' to exclude everything except what you includeincludes:-/home/Pictures# a list of includes, which are full paths-/home/Musicremote:bucket:'<an_s3_bucket>'# S3 bucket namepath:'__test'# subpath within the bucketfull_if_older_than:7D# default is incremental, will create full backup every 7Days.
您可以根据自己的喜好更改配置文件该命令将检查配置的有效性,并告诉您发生了什么错误以及需要纠正什么如果您犯了错误,可以查看duplicity手册页以获取有关该主题的更多信息。然而,我们试图尽可能详细地引导您朝着正确的方向前进
首次备份
打给你的第一个备份,这是一个完整的备份。
duplicity_backup_s3 incr --verbose
# or if the config is somewhere else
duplicity_backup_s3 incr --config /path/to/configuation.yaml
根据备份的大小,这可能需要时间。 您可以看到正在上载到S3 bucket的卷
要检查备份集合,请列出并验证可以使用的备份:
# collection status duplicity_backup_s3 status # list all files duplicity_backup_s3 list # verify backup duplicity_backup_s3 verify
删除旧备份
为了删除旧备份,duplicity提供了一些命令我们在remove
命令中实现了这些。
# to remove backups older than 7D duplicity_backup_s3 remove --older-than 7D # to remove older backup except the last 4 full backups duplicity_backup_s3 remove --all-but-n-full 4
在cronjob中使用此作为每日备份
若要在日常cron作业中使用此选项,可以更改用户的crontab
root
crontab -u root -e
您可以按以下方式更改crontab
# Daily backup and remove older backup 7 4 * * * /bin/duplicity_backup_s3 incr --config=/path/to/conf.yaml && /bin/duplicity_backup_s3 remove --older-than 7D --config=/path/to/conf.yaml # | | | | +- the command to execute # | | | +--- day of the week (0-6) Sunday=0 (*=every day) # | | +----- month of the year (*=every month) # | +------- day of the month (*=every day) # +--------- hour of the day #----------- minute in the hour
待办事项
- []为默认配置文件放置实现appdirs
- []实施恢复以恢复
- []数字海洋测试
- []如果请求,请将
--s3-european-buckets
迁移到配置文件 - []如果需要,实施GPG/加密功能可能重用
kecpkg-tools
的代码来管理证书。 - []初始化为
cron.daily
学分
- 这个包裹的灵感来源于过去口是心非的团队所做的伟大工作
- 这个包的灵感来自于duplicity_backup.sh项目的大量perl/bash代码。
- 这个包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。 \ n\n更改日志
v0.5.0(19年6月5日)
首次公开发行
- 命令
incr
,list
,status
,verify
,cleanup
已实现。 - 为配置文件添加了yaml架构检查。
v0.2.0(19年6月3日)
内部释放
- 迁移到命令结构现在提供
incr
和init
v0.1.0(19年6月3日)
内部释放
- pypi上的第一个版本。