You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 11, 2024. It is now read-only.
How to back up and encrypt data using rsync and VeraCrypt on macOS
Summary
In trying to implement these backup scripts for the first time, I noticed that the call to veracrypt in the dismount() function that's used in backup.sh and restore.sh errors out and fails to find a valid volume if the command is as written. I think it should check whether the mount point is an existing directory, then dismount the volume path, or am I missing something?
This is current state (errors out):
veracrypt --text --dismount "$mount_point"
But it seems not to work unless I change it to this:
Hey @sunknudsen, thanks for the response! I'm not sure what the problem is on my system, because the Veracrypt docs suggest that the "Mount directory of the volume's filesystem (if mounted)" is a valid argument to the --dismount flag, but when I run the script using $mount_point in the dismount function, I get "Error: No such volume is mounted." Maybe it's a weird macOS filesystem thing?
This is what I've been running successfully:
#! /bin/bashset -e
set -o pipefail
functiondismount()
{
if [ -d"$mount_point" ];then
veracrypt --text --dismount "$volume_path"fi
}
trap dismount ERR INT
volume_path="$BACKUP_VOLUME_PATH"
mount_point="/Volumes/Backup"
veracrypt \
--text \
--mount \
--pim "0" \
--keyfiles "" \
--protect-hidden "no" \
"$volume_path" \
"$mount_point"
mkdir -p "$mount_point/Versioning"
files=(
"$HOME/directory1""$HOME/directory2"
)
forfilein"${files[@]}";do
rsync \
-axRS \
--backup \
--backup-dir \
"$mount_point/Versioning" \
--delete \
--suffix="$(date +".%F-%H%M%S")" \
"$file" \
"$mount_point"doneif [ "$(find "$mount_point/Versioning" -type f -ctime +90)"!="" ];thenprintf"Do you wish to prune versions older than 90 days (y or n)? "read -r answer
if [ "$answer"="y" ];then
find "$mount_point/Versioning" -type f -ctime +90 -delete
find "$mount_point/Versioning" -type d -empty -delete
fifi
open "$mount_point"printf"Inspect backup and press enter"read -r answer
dismount
printf"Generate hash (y or n)? "read -r answer
if [ "$answer"="y" ];then
openssl dgst -sha512 "$volume_path"fiprintf"%s\n""Done"
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Guide
How to back up and encrypt data using rsync and VeraCrypt on macOS
Summary
In trying to implement these backup scripts for the first time, I noticed that the call to
veracrypt
in thedismount()
function that's used inbackup.sh
andrestore.sh
errors out and fails to find a valid volume if the command is as written. I think it should check whether the mount point is an existing directory, then dismount the volume path, or am I missing something?This is current state (errors out):
veracrypt --text --dismount "$mount_point"
But it seems not to work unless I change it to this:
veracrypt --text --dismount "$volume_path"
Which would change the whole function to:
Or, in the here document:
System:
The text was updated successfully, but these errors were encountered: