-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CSchloss385
committed
Feb 22, 2017
1 parent
5b2b463
commit 0b9121f
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
#migratelto | ||
#This script transfers files from an LTO tape. Script uses gcp. | ||
|
||
SCRIPTDIR=$(dirname "${0}") | ||
TAPE_MOUNT_POINT="/Volumes" | ||
TAPE_EJECT="Y" | ||
|
||
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ; } | ||
|
||
_usage(){ | ||
echo | ||
echo "This script moves files from an lto tape to another location." | ||
echo "Usage: $(basename "${0}") -t [-e]" | ||
echo " -e state yes (Y) or no (N) to ejecting the tape after migration, default" | ||
echo " is yes" | ||
echo | ||
} | ||
|
||
OPTIND=1 | ||
while getopts ":t:e" opt ; do | ||
case "${opt}" in | ||
t) TAPE_SERIAL="${OPTARG}" ;; | ||
e) TAPE_EJECT="${OPTARG}" ;; | ||
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; | ||
*) echo "Bad option -${OPTARG}" ; _usage ; exit 1 ;; | ||
esac | ||
done | ||
shift $(( ${OPTIND} - 1 )) | ||
|
||
SOURCE_DIR="${1}" | ||
if [[ ! $(echo "${TAPE_SERIAL}" | grep -E "${TAPE_SERIAL_REGEX}") ]] ; then | ||
echo "${TAPE_SERIAL} is not valid. The tape id must be exactly 6 capital letters and/or numbers, possibly followed by 'L5', 'L6' or 'L7' specifying the LTO generation." | ||
_usage | ||
fi | ||
|
||
TAPE_PATH="${TAPE_MOUNT_POINT}/${TAPE_SERIAL}" | ||
_checkdir "${TAPE_PATH}" | ||
|
||
gcp --preserve=mode,timestamps -nRv "${TAPE_PATH}" "${SOURCE_DIR}/"* | ||
|
||
case "${TAPE_EJECT}" in | ||
y|Y) umount "${TAPE_PATH}" ;; | ||
*) echo "Done migrating but not ejecting ${TAPE_SERIAL}." ;; | ||
esac | ||
|