我正在尝试使用双重性来创建一个轮换备份时间表:最后一天的每小时备份、最后一周的每日备份、上个月的每周备份、永远的每月备份(到S3(。
如果有比我要描述的更好的方法来实现这一点,我会接受。但我也会弄清楚为什么这不起作用。
我已经创建了一组脚本:hourly
、hourly_clean
、daily
等,然后将它们放入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
以下是每小时和每天的脚本:
#!/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;
每小时备份工作正常,但其他的AFAICT什么都不做。
如果我尝试手动运行它们,它会发出警告,但没有错误:
$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
-------------------------------------------------
正如我所说,每小时一次的工作很好,但其他人并没有把任何东西推到S3。为什么每天/每周/每月的备份不起作用?或者,有没有更好的方法来达到口是心非的目的?
每日脚本具有选项"--干运行";,根据双面性手册页具有双面性";计算将要做什么,但不执行任何后端操作";。每小时脚本省略了该选项。