從 zfs 增量備份恢復
我通過以下方式創建了 zfs 備份:
- 創建完整備份
zfs snapshot pool/mydata@fullback
zfs send pool/mydata@fullback > /backup/fullback
2.創建五個增量備份incr1 ..incr5
zfs snapshot pool/mydata@incr1
zfs send -i pool/mydata@fullback pool/mydata@incr1 > /backup/incr1
以類似的方式,第五次增量備份是
zfs snapshot pool/mydata@incr5
zfs send -i pool/mydata@fullback pool/mydata@incr5 > /backup/incr5
所以現在我有備份
/backup/fullback
/backup/incr1
/backup/incr2
/backup/incr3
/backup/incr4
/backup/incr5
假設,我必須恢復到第二個增量備份,
zfs receive -F pool/mydata < /backup/incr2
並使用回滾,zfs rollback -r pool/mydata@incr2
我得到了預期。但是如果我想在恢復到第二個增量備份後恢復第五個增量備份,我就會遇到問題。我怎樣才能做到這一點?有什麼辦法可以解決嗎?
由於您的
incr5
備份是針對完整備份進行的(即:通過發出zfs snapshot pool/mydata@incr5; zfs send -i pool/mydata@fullback pool/mydata@incr5 > /backup/incr5
),因此您無法針對另一個備份(即incr2
. 要恢復incr5
,您需要從“普通”fullback
恢復重新啟動。換句話說,您並沒有真正使用增量備份,而是差異備份。對於後者,您需要始終從上次完整備份開始。
或者,您可以切換到真正的增量備份,每個新快照都基於之前的快照,如下所示:
zfs snapshot pool/mydata@fullback; zfs send pool/mydata@fullback > /backup/fullback zfs snapshot pool/mydata@incr1; zfs send -i pool/mydata@fullback pool/mydata@incr1 > /backup/incr1 zfs snapshot pool/mydata@incr2; zfs send -i pool/mydata@incr1 pool/mydata@incr2 > /backup/incr2 zfs snapshot pool/mydata@incrN; zfs send -i pool/mydata@incrN-1 pool/mydata@incrN > /backup/incrN