一个简单的s3备份脚本
Humus的Python项目详细描述
humus是一个定期将大块数据(如数据库备份)备份到amazon的s3的工具。腐殖质的特性包括:
- cli工具和python库。
- 自动文件旋转
- 自动基于日期的文件修剪。
为什么要使用另一个S3备份工具?
现在的大多数备份工具要么是备份了整个文件目录,要么是没有提供我正在寻找的旋转/修剪工具。
安装和使用
运行pip install humus。
在./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 >
每当您想进行新备份时,请运行命令humus my_filename target_file或output_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