Add: rsync script for incremental backups

This commit is contained in:
Aroy-Art 2023-09-08 10:15:14 +02:00
parent f54b2e7961
commit ac1720f700
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -0,0 +1,26 @@
#!/bin/bash
# A script to perform incremental backups using rsync
set -o errexit
set -o nounset
set -o pipefail
#readonly SOURCE_DIR="${HOME}"
readonly SOURCE_DIR="<input folder>"
readonly BACKUP_DIR="<output folder>"
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
readonly BACKUP_PATH="${BACKUP_DIR}/${DATETIME}"
readonly LATEST_LINK="${BACKUP_DIR}/latest"
mkdir -p "${BACKUP_DIR}"
rsync -ahv --progress --stats --delete \
--log-file="${BACKUP_DIR}/${DATETIME}.log" \
--exclude=".cache" \
--link-dest "${LATEST_LINK}" \
"${SOURCE_DIR}/" \
"${BACKUP_PATH}"
rm -rfv "${LATEST_LINK}"
ln -s "${BACKUP_PATH}" "${LATEST_LINK}"