Created
March 15, 2023 14:24
-
-
Save Luxian/81ca8074c47e5bf7bc8c0ac7662506bf to your computer and use it in GitHub Desktop.
rsync backup script
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
#!/usr/bin/env bash | |
# -e: Exit at the first failed command | |
# -u: Unset variables are errors (exit script) | |
set -eu | |
sudo mkdir -p /var/log/[nasname]-backup | |
BACKUP_TIMESTAMP=$(date +%Y.%m.%d-%H.%M.%S); | |
( | |
time sudo \ | |
rsync \ | |
--archive \ | |
--human-readable \ | |
--verbose \ | |
--executability \ | |
--whole-file \ | |
--delete \ | |
-e "ssh -i /home/[servername]/.ssh/id_ed25519" \ | |
/mnt/volume01 \ | |
[mynasuser]@[mynashostname]::backup/[servername] \ | |
) 2>&1 | sudo tee /var/log/[nasname]-backup/backup-${BACKUP_TIMESTAMP}.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment