In back up script, some clean ups.

Removed backslashes, add curly brackets to variable references.
This commit is contained in:
Tod Fitch 2020-09-14 19:45:45 -07:00
parent 431339d008
commit 76b7d64f8c

View file

@ -208,7 +208,7 @@ function cleanup()
trap cleanup ERR INT trap cleanup ERR INT
veracrypt --text --mount --pim 0 --keyfiles "" --protect-hidden no "$BACKUP_VOLUME_PATH" /Volumes/Backup veracrypt --text --mount --pim 0 --keyfiles "" --protect-hidden no "${BACKUP_VOLUME_PATH}" /Volumes/Backup
mkdir -p /Volumes/Backup/Versioning mkdir -p /Volumes/Backup/Versioning
@ -218,14 +218,16 @@ declare -a files=(
"/Users/$(whoami)/Library/Keychains" "/Users/$(whoami)/Library/Keychains"
) )
for file in "\${files[@]}"; do timestamp=$(date +'.%F_%H-%M')
rsync -axRS --delete --backup --backup-dir /Volumes/Backup/Versioning --suffix=\$(date +'.%F_%H-%M') "\$file" /Volumes/Backup
for file in "${files[@]}"; do
rsync -axRS --delete --backup --backup-dir /Volumes/Backup/Versioning --suffix="${timestamp}" "${file}" /Volumes/Backup
done done
if [ "\$(find /Volumes/Backup/Versioning -type f -ctime +90)" != "" ]; then if [ "$(find /Volumes/Backup/Versioning -type f -ctime +90)" != "" ]; then
printf "Do you wish to prune versions older than 90 days (y or n)? " printf "Do you wish to prune versions older than 90 days (y or n)? "
read -r answer read -r answer
if [ "\$answer" = "y" ]; then if [ "${answer}" = "y" ]; then
find /Volumes/Backup/Versioning -type f -ctime +90 -delete find /Volumes/Backup/Versioning -type f -ctime +90 -delete
find /Volumes/Backup/Versioning -type d -empty -delete find /Volumes/Backup/Versioning -type d -empty -delete
fi fi
@ -241,7 +243,7 @@ veracrypt --text --dismount "$BACKUP_VOLUME_PATH"
printf "Generate hash (y or n)? " printf "Generate hash (y or n)? "
read -r answer read -r answer
if [ "\$answer" = "y" ]; then if [ "${answer}" = "y" ]; then
openssl dgst -sha512 "$BACKUP_VOLUME_PATH" openssl dgst -sha512 "$BACKUP_VOLUME_PATH"
fi fi