有人可以解釋一下如何循環備份邏輯(下面提到的腳本)

有人可以解釋一下如何循環備份邏輯(下面提到的腳本)

有人可以解釋我如何循環以下邏輯,該邏輯需要每週運行一次。例如:在第一周,在來源資料夾中,我有一個名為 stack.txt、webmethods、profiles 的檔案和資料夾,因此當我執行邏輯時,所有這些檔案都會備份到目標資料夾。在第二週,在來源資料夾中新增了額外的目錄,即 Kafka,所以現在當邏輯運行時,它不應該完全備份,只備份新添加的東西..例如增量備份

#!/bin/bash

# What to backup. 
Integrationserver="/home/ec2-user/source"

# Where to backup to.
dest="/home/ec2-user/destination"


# Create archive filename.
#date=$(date +%F)
IS=source
hostname=$(hostname -s)
#archive_file="$hostname-$IS-$date.tar.gz"
archive_file="$hostname-$IS.tar.gz"

# Print start status message.
echo "Backing up $Integrationserver to $dest/$archive_file"
date
echo

# Backup the files using tar.
tar --exclude=/home/ec2-user/source/logs* --exclude=/home/ec2-user/source/TC*  -zcf $dest/$archive_file $Integrationserver

# Print end status message.
echo
echo "Backup finished"
date

答案1

要在設定的時間多次運行它,您應該使用 cron 或等效的發行版。

至於使用 tar 檔案進行增量,您需要使用 --listed-incremental

它有點複雜,所以我將連結一篇總結它的文章,這樣我就不必這樣做了。

https://linuxconfig.org/how-to-create-incremental-and- Differential-backups-with-tar

相關內容