长话短说
rsnapshot 是否有一些配置(请参阅下面的版本),允许我将输出限制为 rsnapshot 本身生成的 shell 命令、错误和开始/完成通知,同时使 rsync 生成并记录所需的详细信息级别仅有的在 rsync 日志文件中?或者更简洁地说,我可以使 rsnapshot 输出的结果与 rsnapshot 配置文件中的详细描述相匹配吗?
如果没有,是否有一个 rsnapshot 社区可以接受功能请求?
只是TL部分...
经过一些故障排除(见下文)后,我的 rsnapshot 和 rsync 的特定组合似乎不再像前几年那样工作。具体来说,无论 .rsync 中的详细设置如何,rsync 的输出现在都显示在 rsnapshot 的控制台输出中rsnapshot.conf
。我全新安装了 FreeBSD 12.2
freebsd-version
12.2-RELEASE-p10
rsync 作为 的一部分安装pkg install rsnapshot
,并rsync -V
显示
rsync version 3.2.3 protocol version 31
Copyright (C) 1996-2020 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, hardlink-specials, symlinks, IPv6, atimes,
batchfiles, inplace, append, ACLs, xattrs, optional protect-args, iconv,
symtimes, no prealloc, stop-at, no crtimes, file-flags
Optimizations:
no SIMD, no asm, openssl-crypto
Checksum list:
xxh128 xxh3 xxh64 (xxhash) md5 md4 none
Compress list:
zstd lz4 zlibx zlib none
rsnapshot 的当前版本是:
my $VERSION = '1.4.4';
在发布这个问题的原始形式并沉睡之后,加上前面提到的故障排除,问题归结为:rsnapshot 从 crontab 运行,并且 rsync 中不必要的信息出现在控制台输出中(尽管有 verbose 1 设置)似乎需要一个“包装器”脚本来抑制噪音,然后从 rsnapshot 日志中组装正确的信息。这似乎是一个非常容易出错的过程,而且维护成本也可能非常高,因为升级打破了解决方法的管道胶带性质。
成本最低的路径似乎是放弃获取有关 rsync 传输有效性的任何统计信息。这使我能够保持监视 rsync 成功/失败的可读性,并在失败时轻松重新运行它。
显然有些东西已经改变了,我怀疑 rsync (隐式 -v 设置?),并且是否有一些配置允许我在 rsnapshot 输出中获得我想要的内容(仅 shell 命令、错误和开始/完成通知)在 rsync 日志文件中记录 rsync 输出,我很想知道它。
请记住,rsnapshot 机制自 2018 年以来一直运行良好,只有全新安装 FreeBSD 12.2 才会破坏它。以前的 rsnapshot 机制在升级的 FreeBSD 12.1(以 10.x 启动)上运行(在相同的硬件上)。 rsync 和 rsnapshot 最初是与 FreeBSD 10.x ports 分开构建的(按顺序),并从那时起通过 portmaster 定期升级。
这次(如前所述)我使用 pkg 安装了 rsnapshot,并让它安装 rsync(以及它需要的其他所有内容)。
rsnapshot.conf 仅更改了值snapshot_root
和缩短的备份点列表。
这是我想要的监控电子邮件的输出(易于处理)(即没有所有 rsync 噪音):
Wed Oct 20 21:40:00 PDT 2021
=================================================================
echo 98875 > /var/run/rsnapshot.pid
mv /obo-offsitepool/archives/daily.5/ /obo-offsitepool/archives/daily.6/
mv /obo-offsitepool/archives/daily.4/ /obo-offsitepool/archives/daily.5/
mv /obo-offsitepool/archives/daily.3/ /obo-offsitepool/archives/daily.4/
mv /obo-offsitepool/archives/daily.2/ /obo-offsitepool/archives/daily.3/
mv /obo-offsitepool/archives/daily.1/ /obo-offsitepool/archives/daily.2/
native_cp_al("/obo-offsitepool/archives/daily.0", \
"/obo-offsitepool/archives/daily.1")
/usr/local/bin/rsync -a --delete --numeric-ids \
/obo-offsitepool/archives/daily.0/ /obo-offsitepool/archives/daily.1/
/usr/local/bin/rsync -rltv --chmod D0770,F0660 --delete --relative \
--delete-excluded --partial --stats --log-file=/var/log/rsync \
--human-readable \
--exclude-from=/obo-offsitepool/archives/.rsnapshot_excludes \
/usr/local/etc/ \
/obo-offsitepool/archives/daily.0/obo-offsite1/local_etc/
/usr/local/bin/rsync -rltv --chmod D0770,F0660 --delete --relative \
--delete-excluded --partial --stats --log-file=/var/log/rsync \
--human-readable \
--exclude-from=/obo-offsitepool/archives/.rsnapshot_excludes \
192.168.18.3::srv330-group/ \
/obo-offsitepool/archives/daily.0/CSO/srv330-group
... etc
而不是这个(请记住,有 >20 个备份点,其中许多有数百行不需要的 rsync 输出):
Tue Oct 26 18:55:00 PDT 2021
=================================================================
echo 97810 > /var/run/rsnapshot.pid
/bin/rm -rf /obopool/archives/daily.6/
mv /obopool/archives/daily.5/ /obopool/archives/daily.6/
mv /obopool/archives/daily.4/ /obopool/archives/daily.5/
mv /obopool/archives/daily.3/ /obopool/archives/daily.4/
mv /obopool/archives/daily.2/ /obopool/archives/daily.3/
mv /obopool/archives/daily.1/ /obopool/archives/daily.2/
native_cp_al("/obopool/archives/daily.0", \
"/obopool/archives/daily.1")
/usr/local/bin/rsync -a --delete --numeric-ids \
/obopool/archives/daily.0/ /obopool/archives/daily.1/
/usr/local/bin/rsync -rltv --chmod D0770,F0660 --delete --relative \
--delete-excluded --partial --stats --log-file=/var/log/rsync \
--human-readable \
--exclude-from=/obopool/archives/.rsnapshot_excludes /usr/local/etc/ \
/obopool/archives/daily.0/offsite1/local_etc/
sending incremental file list
/usr/
deleting usr/local/etc/ssmtp/ssmtp.conf.sample
deleting usr/local/etc/ssmtp/ssmtp.conf.2021-01-20
deleting usr/local/etc/ssmtp/ssmtp.conf
deleting usr/local/etc/ssmtp/revaliases.sample
deleting usr/local/etc/ssmtp/revaliases
deleting usr/local/etc/ssmtp/
deleting usr/local/etc/dma/dma.conf.sample
deleting usr/local/etc/dma/dma.conf
deleting usr/local/etc/dma/auth.conf.sample
deleting usr/local/etc/dma/auth.conf
deleting usr/local/etc/dma/
deleting usr/local/etc/portmaster.rc.sample
deleting usr/local/etc/papersize.letter
deleting usr/local/etc/papersize.a4
deleting usr/local/etc/bash_completion.d/portmaster.sh
deleting usr/local/etc/rc.d/dma_flushq
/usr/local/
/usr/local/etc/
/usr/local/etc/rsnapshot.conf
/usr/local/etc/rsnapshot.conf.default
/usr/local/etc/rsnapshot.conf_2018-09-08
/usr/local/etc/rsnapshot.conf_2019-06-14
/usr/local/etc/rsnapshot.conf_2019-08-23
/usr/local/etc/rsnapshot.conf_2021-02-01
/usr/local/etc/rsnapshot.conf_2021-06-21
/usr/local/etc/screenrc
/usr/local/etc/screenrc.sample
/usr/local/etc/smartd.conf
/usr/local/etc/smartd.conf.sample
/usr/local/etc/smartd_warning.sh
/usr/local/etc/bash_completion.d/
/usr/local/etc/man.d/
/usr/local/etc/man.d/perl5.conf
/usr/local/etc/newsyslog.conf.d/
/usr/local/etc/newsyslog.conf.d/rsnapshot
/usr/local/etc/newsyslog.conf.d/rsync
/usr/local/etc/newsyslog.conf.d/rsyncd
/usr/local/etc/periodic/
/usr/local/etc/periodic/daily/
/usr/local/etc/periodic/daily/smart
/usr/local/etc/periodic/security/
/usr/local/etc/periodic/weekly/
/usr/local/etc/rc.d/
/usr/local/etc/rc.d/rsyncd
/usr/local/etc/rc.d/smartd
/usr/local/etc/rc.d/uuidd
/usr/local/etc/rsync/
/usr/local/etc/rsync/rsyncd.conf
/usr/local/etc/rsync/rsyncd.conf.sample
/usr/local/etc/smartd_warning.d/
/usr/local/etc/ssl/
/usr/local/etc/ssl/cert.pem
Number of files: 46 (reg: 31, dir: 14, link: 1)
Number of created files: 4 (reg: 3, dir: 1)
Number of deleted files: 16 (reg: 14, dir: 2)
Number of regular files transferred: 23
Total file size: 774.49K bytes
Total transferred file size: 735.92K bytes
Literal data: 735.92K bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 738.45K
Total bytes received: 1.10K
sent 738.45K bytes received 1.10K bytes 1.48M bytes/sec
total size is 774.49K speedup is 1.05
/usr/local/bin/rsync -rltv --chmod D0770,F0660 --delete --relative \
--delete-excluded --partial --stats --log-file=/var/log/rsync \
--human-readable \
--exclude-from=/obopool/archives/.rsnapshot_excludes \
192.168.18.3::srv330-group/ \
/obopool/archives/daily.0/CSO/srv330-group
receiving incremental file list
CSO2/Lori/
CSO2/Lori/retail.prices2.docx
Retail/
...etc
上述两份电子邮件报告都是从同一个 rsnapshot.conf 文件生成的。
这是我一直在做的故障排除。测试 4 是与我之前的测试最接近的测试。
1
rsnapshot -v alpha && /root/scripts/marklogs.sh --> using default rsnapshot.conf with
entries for rsync_short_args AND rsync_long_args were actually elided from file (not left with # symbol)
- normal screen output (start notification, shell commands, success notification)
- rsnapshot log shows same as monitor output, no rsync log output
2 Explicitly add in default settings to the rsnapshot.conf file
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed as shown:
rsync_short_args -a
rsync_long_args --delete --numeric-ids --relative --delete-excluded
- same as previous
3 change rsync_long_args
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed from default as shown:
rsync_short_args -a
rsync_long_args --chmod D0770,F0660 --delete --relative --delete-excluded --partial --log-file=/var/log/rsync-test
- console shows expected output (start notification, shell commands, success confirmations)
- rsnapshot log shows same as monitor output
- rsync log shows building file list, files xferred, sent/received/total summary line for each backup point
4 change rsync_short args
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed from default as shown:
rsync_short_args -rlt
rsync_long_args --chmod D0770,F0660 --delete --relative --delete-excluded --partial --log-file=/var/log/rsync-test
- normal console output (start notification, shell commands, success notification)
- rsnapshot log shows same as console
- rsync log shows building file list, files xferred, sent/received/total summary line for each backup point
5 change rsync_short_arg to add -v
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed from default as shown:
rsync_short_args -rltv
rsync_long_args --chmod D0770,F0660 --delete --relative --delete-excluded --partial --log-file=/var/log/rsync-test
- console shows the unexpected (and undesired), given verbose set at 2, rsync output
- rsnapshog log is polluted with rsync output, shows the start notification & shell commands before the noise, then some closing shell commands (touch /obopool/tester/alpha.0/; rm -f /var/run/rsnapshot.pid) then the completion notification
- rsync log adds one line, "total size ..... speedup is .....", to logged info.
6 change loglevel to 1 to see effect on rsnapshot log
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed from default as shown:
loglevel 1
rsync_short_args -rltv
rsync_long_args --chmod D0770,F0660 --delete --relative --delete-excluded --partial --log-file=/var/log/rsync-test
- console shows same polluted output (rsnapshot shell commands with rsync data)
- rsnapshot log received no ouput
- rsync log shows same (correct) output as previous execution
7 change verbose to 1 (quiet) in rsnapshot.conf
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed as shown:
verbose 1
loglevel 1
rsync_short_args -rltv
rsync_long_args --chmod D0770,F0660 --delete --relative --delete-excluded --partial --log-file=/var/log/rsync-test
- console - no change to output from test 6
- rsnapshot log received no ouput (expected with loglevel 1)
- rsync log shows expected output (same as previous)
8 set loglevel to 2 to verify effect on rsnapshot log
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed as shown:
verbose 1
loglevel 2
rsync_short_args -rltv
rsync_long_args --chmod D0770,F0660 --delete --relative --delete-excluded --partial --log-file=/var/log/rsync-test
- console - no change
- rshapshot log shows only start and completion notices (no shell commands). One assumes errors would show up.
- rsync log shows expected output
9 variation on 4: default verbose/log level - no -v on rsync_short_args, and add --stats to rsync long args
rm -rf /obopool/tester/alpha* && rsnapshot -v alpha && /root/scripts/marklogs.sh #--> rsnapshot.conf modifed from default as shown:
rsync_short_args -rlt
rsync_long_args --chmod D0770,F0660 --delete --relative --delete-excluded --partial --log-file=/var/log/rsync-test --stats
- console has stats (rsync) information mixed in with correct output (start notification, shell commands, success confirmations)
- rshapshot log has the same issues as console: stats output mixed in with expected output (start notification, shell commands, success confirmations)
- rsync log shows expected output -- files plus stats.
这是默认(已安装)/usr/local/etc/rsnapshot.conf
文件,所有记录的更改均针对该文件进行。
#/usr/local/etc/rsnapshot.conf
#################################################
# rsnapshot.conf - rsnapshot configuration file #
#################################################
# #
# PLEASE BE AWARE OF THE FOLLOWING RULE: #
# #
# This file requires tabs between elements #
# #
#################################################
#######################
# CONFIG FILE VERSION #
#######################
config_version 1.2
snapshot_root /obopool/tester
no_create_root 1
cmd_rm /bin/rm
cmd_rsync /usr/local/bin/rsync
cmd_logger /usr/bin/logger
#cmd_rsnapshot_diff /usr/local/bin/rsnapshot-diff
retain alpha 6
retain beta 7
retain gamma 4
#retain delta 3
# Verbose level, 1 through 5.
# 1 Quiet Print fatal errors only
# 2 Default Print errors and warnings only
# 3 Verbose Show equivalent shell commands being executed
# 4 Extra Verbose Show extra verbose information
# 5 Debug mode Everything
#
verbose 2
# Same as "verbose" above, but controls the amount of data sent to the
# logfile, if one is being used. The default is 3.
#
loglevel 3
logfile /var/log/rsnapshot-test
lockfile /var/run/rsnapshot.pid
###############################
### BACKUP POINTS / SCRIPTS ###
###############################
# LOCALHOST
backup /root/ localhost/
backup /etc/ localhost/
backup /usr/local/ localhost/
backup /var/log/ localhost/
最后,这是一些perl -V
输出
perl -V
Summary of my perl5 (revision 5 version 32 subversion 1) configuration:
Platform:
osname=freebsd
osvers=12.2-release-p10
archname=amd64-freebsd-thread-multi
uname='freebsd 122amd64-quarterly-job-03 12.2-release-p10 freebsd 12.2-release-p10 amd64 '
config_args='-Darchlib=/usr/local/lib/perl5/5.32/mach -Dcc=cc -Dcf_by=mat [email protected] -Dcf_time=Sat Jan 23 14:56:40 UTC 2021 -Dinc_version_list=none -Dlibperl=libperl.so.5.32.1 -Dman1dir=/usr/local/lib/perl5/5.32/perl/man/man1 -Dman3dir=/usr/local/lib/perl5/5.32/perl/man/man3 -Dprefix=/usr/local -Dprivlib=/usr/local/lib/perl5/5.32 -Dscriptdir=/usr/local/bin -Dsitearch=/usr/local/lib/perl5/site_perl/mach/5.32 -Dsitelib=/usr/local/lib/perl5/site_perl -Dsiteman1dir=/usr/local/lib/perl5/site_perl/man/man1 -Dsiteman3dir=/usr/local/lib/perl5/site_perl/man/man3 -Dusenm=n -Duseshrplib -sde -Ui_iconv -Ui_malloc -Uinstallusrbinperl -Accflags=-DUSE_THREAD_SAFE_LOCALE -Alddlflags=-L/wrkdirs/usr/ports/lang/perl5.32/work/perl-5.32.1 -L/usr/local/lib/perl5/5.32/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS:N-L/wrkdirs/usr/ports/lang/perl5.32/work/perl-5.32.1:N-L/usr/local/lib/perl5/5.32/mach/CORE:N-lperl) -Wl,-soname,$(LIBPERL:R) -Doptimize=-O2 -pipe -fstack-protector-strong -fno-strict-aliasing -Dusedtrace -Ui_gdbm -Dusemultiplicity=y -Duse64bitint -Dusemymalloc=n -Dusethreads=y'
答案1
看起来你已经有了rsync -v
。去掉-v
后rsync
就会安静很多。
rsync_short_args
您可以通过最初查看和 的值来检查这一点rsync_long_args
;以下是我的配置示例:
rsync_short_args -azHS
rsync_long_args --delete --delete-excluded --numeric-ids --fake-super
如果省略这些值,您将依赖默认值保持不变。的变更日志rsnapshot
应该声明默认值是否已更改,但通过使用您自己的定义,您可以完全绕过该问题。