-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_data.sh
More file actions
executable file
·46 lines (35 loc) · 1.49 KB
/
copy_data.sh
File metadata and controls
executable file
·46 lines (35 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -e
if [ $# -lt 1 ]
then
echo """
This script copies a tarball and its .tar.sha512 file onto tape. Must be run
from tigrsrv with the correct tape already mounted. See our admin docs
for more info on inserting and mounting a tape:
https://github.com/TIGRLab/admin/wiki/Tape-Drive
The script takes a file name without an extension or preceding path. It will
copy the files to tape, and then read them back from tape and hash the copy
to ensure the tape copy is identical and readable (DON'T try to skip this step
to save time!).
Env vars read by this script:
- TAPE_WORK_DIR: where the original file is expected to be found
(default: "$TAPE_WORK_DIR")
- TAPE_PULL_DIR: The directory to pull the file to and store the results
of hashing it. (default: "$TAPE_PULL_DIR")
- TAPE_SCRIPTS: The directory other tape scripts can be found in.
(default: "$TAPE_SCRIPTS")
- HASH_NODE: The node on our network to use when hashing data
(default: "$HASH_NODE")
Usage:
copy_data.sh <file_name>
"""
exit 2
fi
# This should be a file name, no extension, no path
fname=$1
# make the copy on tape
cp ${TAPE_WORK_DIR}/${fname}.tar* /mnt/ltfs/
# Pull it back to test correctness and readability of copy
cp /mnt/ltfs/${fname}.* ${TAPE_PULL_DIR}/
# Kick off the hashing to ensure the tape copy is correct
sudo -i -u localadmin ssh ${HASH_NODE} "cd ${TAPE_PULL_DIR}; sudo nohup sha512sum --check ${fname}.tar.sha512 > ${fname}.log 2> ${fname}.err < /dev/null &"