![有人可以解釋一下如何循環備份邏輯(下面提到的腳本)](https://rvso.com/image/1672331/%E6%9C%89%E4%BA%BA%E5%8F%AF%E4%BB%A5%E8%A7%A3%E9%87%8B%E4%B8%80%E4%B8%8B%E5%A6%82%E4%BD%95%E5%BE%AA%E7%92%B0%E5%82%99%E4%BB%BD%E9%82%8F%E8%BC%AF%EF%BC%88%E4%B8%8B%E9%9D%A2%E6%8F%90%E5%88%B0%E7%9A%84%E8%85%B3%E6%9C%AC%EF%BC%89.png)
有人可以解釋我如何循環以下邏輯,該邏輯需要每週運行一次。例如:在第一周,在來源資料夾中,我有一個名為 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