![]() By convention, scripts should be silent if there is nothing important to report, and any error messages should go to standard error rather than standard output.This way, no word splitting happens on the input, and commands within the while loop which happen to read from stdin won't break the loop. While read -r -u9 drive_number volume_location vc_mapper mount_location while read -r drive_number volume_location vc_mapper mount_location.First, because quotes are actually valid characters in paths, but more importantly because it is a strong indication that you're expecting the user to wrongly input broken strings. Instead, remove the sudos and tell the user to run the whole script as root. Using sudo within a script is generally discouraged, since it makes it easy to do really bad things without explicit user consent.function prepare_volumes_for_exit() can be simplified to prepare_volumes_for_exit().#!/usr/bin/env bash is a more portable shebang line.# sudo rsync -hrtq -exclude-from='/media/miller/Primary/exclude.txt' -delete $source_mount_point/ $backup_mount_pointĮcho 'Error: Drives were not mounted successfully, skipping rsync' ![]() # checks both the source and backup volumes are mountedĮlif & thenĮcho "Error: source or backup volume not mounted" Sudo veracrypt -t -mount "$backup_volume_path" "$backup_mount_point" -p "$veracrypt_password" -non-interactive While read -r drive_number volume_location vc_mapper mount_location doįormatted_volume_location="$(format_string "$volume_location")"įormatted_mount_location="$(format_string "$mount_location")" It can also encrypt a partition 6 or (in Windows ) the entire storage device with pre-boot authentication. The software can create a virtual encrypted disk that works just like a regular disk but within a file. Sudo veracrypt -t -mount "$source_volume_path" "$source_mount_point" -p "$veracrypt_password" -non-interactive VeraCrypt is a free and open-source utility for on-the-fly encryption (OTFE). # flag to determine if drives are mounted Source_mount_point="$(format_string "/mnt/$(uuidgen)")"īackup_mount_point="$(format_string "/mnt/$(uuidgen)")" # make sure all volumes are removed before startingĮcho "Error: 2 parameters are required "Įcho "Enter the password for the veracrypt volume: " # removes double or single quotes from strings of they exist # - Both volumes must have the same password # - Must have both veracrypt and rsync installed This is my second time with bash scripting so please let me know what I could do better. I wrote this script so rsync wouldn't have to copy an entire volume if there was a single change in it. ![]() The script takes two parameters, the path for both the source and backup veracrypt volumes. My bash script mounts two VeraCrypt volumes, rsyncs their contents, and dismounts them. With security being a growing concern for many computer users, new options for protecting files.
0 Comments
Leave a Reply. |