長話短說
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
應該會聲明預設值是否已更改,但透過使用您自己的定義,您可以完全繞過該問題。