Created
March 17, 2023 07:26
rsync备份用户主目录
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A script to perform incremental backups using rsync | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
readonly SOURCE_DIR="${HOME}" | |
readonly BACKUP_DIR="/Volumes/Passport/Backup/Backup" | |
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 --append \ | |
--link-dest "${LATEST_LINK}" \ | |
-e "ssh -p 20012" \ | |
root@10.254.1.150:"${SOURCE_DIR}/" \ | |
--exclude-from=exclude-file.txt \ | |
"${BACKUP_PATH}" | |
rm -rf "${LATEST_LINK}" | |
ln -s "${BACKUP_PATH}" "${LATEST_LINK}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment