-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtarball.sh
More file actions
28 lines (24 loc) · 1.18 KB
/
tarball.sh
File metadata and controls
28 lines (24 loc) · 1.18 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
#!/bin/bash
set -eo pipefail
#run with one positional argument - a folder in rds/sharedData to archive
#turn it into its actual real path as that's what we need
TOTARBALL=$(realpath $1)
#first off, are we even in sharedData here?
if [ $(echo ${TOTARBALL} | grep "/rds/project/rds-C9woKbOCf2Y/sharedData" | wc -l) == 0 ]
then
echo "Not a /rds/project/rds-C9woKbOCf2Y/sharedData path, exiting"
exit 1
fi
#need to prepare the path where this will end up
#replace current sharedData path with the tape one
TARBALLDIR=$(dirname ${TOTARBALL} | sed "s|/rds/project/rds-C9woKbOCf2Y/sharedData|/rcs/project/sat1003/rcs-sat1003-teichlab-cold/sharedData_CSCI_tarballs|")
#the name is simple, just the basename with a .tar.gz at the end
TARBALLNAME=$(basename ${TOTARBALL}.tar.gz)
#and we're good. commencing tarballing
mkdir -p ${TARBALLDIR}
#need to actually park myself in the folder with this subfolder in it
#as otherwise the entire path is somehow preserved in the resulting extraction
cd $(dirname ${TOTARBALL})
#this now just makes a single folder when extracted
#a list of contents can be examined via tar -tzvf in its .tar.gz form too
tar -czvf ${TARBALLDIR}/${TARBALLNAME} $(basename ${TOTARBALL})