简体   繁体   English

如何将重复性用于轮换备份计划

[英]How to use duplicity for a rotating backup schedule

I'm trying to use duplicity to create a rotating backup schedule: hourly backups for the last day, daily backups for the last week, weekly backups for the last month, monthly backups forever (to S3).我正在尝试使用重复性来创建轮换备份计划:最后一天的每小时备份,上周的每日备份,上个月的每周备份,永久每月备份(到 S3)。

If there's a better way to accomplish this than what I'm about to describe, I'll take it.如果有比我将要描述的更好的方法来实现这一点,我会接受的。 But I'll also take figuring out why this isn't working.但我也会弄清楚为什么这不起作用。

I've created a set of scripts: hourly , hourly_clean , daily , etc...., and then put them in cron我创建了一组脚本: hourlyhourly_cleandaily等......,然后将它们放入 cron

 12  *  *  *  * root /etc/duplicity_backup/hourly
 16  *  *  *  * root /etc/duplicity_backup/hourly_clean
 18  2  *  *  * root /etc/duplicity_backup/daily
 22  2  *  *  * root /etc/duplicity_backup/daily_clean
 24  3  *  *  7 root /etc/duplicity_backup/weekly
 28  3  *  *  7 root /etc/duplicity_backup/weekly_clean
 30  4  28 *  * root /etc/duplicity_backup/monthly

Here are the hourly and daily scripts:以下是每小时和每天的脚本:

#!/usr/bin/ksh
#
# hourly
#
AWS_ACCESS_KEY_ID=<my_key_id>;
AWS_SECRET_ACCESS_KEY=<my_key>;
PASSPHRASE=foo;

export AWS_ACCESS_KEY_ID;
export AWS_SECRET_ACCESS_KEY;
export PASSPHRASE;

/usr/local/bin/duplicity --archive-dir /mnt/data/var/cache/duplicity \
    --name webserver_vhosts --s3-region-name eu-central-1 \
    --tempdir /mnt/data/var/tmp/ \
    --full-if-older-than 1D \
    --include **/wp-content \
    --exclude **/wp-content/themes --exclude **/wp-content/plugins \
    /mnt/data/www/vhosts/ boto3+s3://mirovoy-backup-webserver/hourly;

#!/usr/bin/ksh
#
# daily
#
AWS_ACCESS_KEY_ID=<my_key_id>;
AWS_SECRET_ACCESS_KEY=<my_key>;
PASSPHRASE=foo;

export AWS_ACCESS_KEY_ID;
export AWS_SECRET_ACCESS_KEY;
export PASSPHRASE;

/usr/local/bin/duplicity full --archive-dir /mnt/data/var/cache/duplicity \
    --dry-run --name webserver_vhosts --s3-region-name eu-central-1 \
    --tempdir /mnt/data/var/tmp/ \
    --full-if-older-than 1W \
    --s3-use-ia \
    --include **/wp-content \
    --exclude **/wp-content/themes --exclude **/wp-content/plugins \
    /mnt/data/www/vhosts/ boto3+s3://mirovoy-backup-webserver/daily;

The hourly backups work fine, but the others, AFAICT, don't do anything.每小时备份工作正常,但其他人,AFAICT,不做任何事情。

If I try and run them manually, it gives a warning, but no errors:如果我尝试手动运行它们,它会发出警告,但没有错误:

$sudo ./daily
Warning, found signatures but no corresponding backup files
Sync would remove the following spurious local files:
duplicity-full-signatures.20210317T001201Z.sigtar.gz
duplicity-full-signatures.20210319T011202Z.sigtar.gz
duplicity-full.20210317T001201Z.manifest
duplicity-full.20210319T011202Z.manifest
duplicity-inc.20210317T001201Z.to.20210317T011201Z.manifest
duplicity-inc.20210317T011201Z.to.20210317T021201Z.manifest
[... lots more local files]
Last full backup date: none
--------------[ Backup Statistics ]--------------
StartTime 1616136196.38 (Fri Mar 19 06:43:16 2021)
EndTime 1616136207.36 (Fri Mar 19 06:43:27 2021)
ElapsedTime 10.98 (10.98 seconds)
SourceFiles 97158
SourceFileSize 1083141759 (1.01 GB)
NewFiles 54089
NewFileSize 1083141759 (1.01 GB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 54089
RawDeltaSize 0 (0 bytes)
TotalDestinationSizeChange 0 (0 bytes)
Errors 0
-------------------------------------------------

As I said, the hourly works fine, but the others aren't pushing anything to S3.正如我所说,每小时工作正常,但其他人没有向 S3 推送任何内容。 Why are the daily/weekly/monthly backups not working?为什么每日/每周/每月备份不起作用? Alternatively, is there a better way to get duplicity to accomplish this?或者,有没有更好的方法来实现这一点?

The daily script has the option "--dry-run", which according to the duplicity man page has duplicity "Calculate what would be done, but do not perform any backend actions".每日脚本具有选项“--dry-run”,根据 duplicity 手册页,该选项具有重复性“计算将要执行的操作,但不执行任何后端操作”。 The hourly script omits that option.每小时脚本省略了该选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM