Add: rsync script for incremental backups
This commit is contained in:
parent
f54b2e7961
commit
ac1720f700
1 changed files with 26 additions and 0 deletions
26
ShellScripts/rsync-incremental-backups.sh
Normal file
26
ShellScripts/rsync-incremental-backups.sh
Normal 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}"
|
Loading…
Reference in a new issue