12345678910111213141516171819202122232425 |
- #!/usr/bin/env bash
- set -euo pipefail # bash strict mode
- # A script to perform incremental backups using rsync
- set -o errexit
- set -o nounset
- set -o pipefail
- readonly SOURCE_DIR="${HOME}"
- readonly BACKUP_DIR="${BACKUPS:-/mnt/crucial_nvme/Backups}"
- 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 -av --delete \
- "${SOURCE_DIR}/" \
- --link-dest "${LATEST_LINK}" \
- --exclude=".cache" \
- "${BACKUP_PATH}"
- rm -rf "${LATEST_LINK}"
- ln -s "${BACKUP_PATH}" "${LATEST_LINK}"
|