-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdelete-bucket.sh
More file actions
28 lines (24 loc) · 871 Bytes
/
delete-bucket.sh
File metadata and controls
28 lines (24 loc) · 871 Bytes
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
#
# Delete a big google bucket using gsutil.
# Instead of showing the name of every deleted file,
# Just count the lines of output from gsutil and log progress instead.
#
# Usage:
#
# delete-bucket.sh bucket-name approximate-bucket-filecount
#
BUCKET_NAME=$1
NUM_FILES=#{2-100000000}
LOG_FILE=${BUCKET_NAME}-DELETION.log
SLOTS=32
CMD="gsutil -o GSUtil:parallel_process_count=${SLOTS} -o GSUtil:parallel_thread_count=4 -m rm -r gs://${BUCKET_NAME}"
if [[ $2 == "local" ]]; then
echo "${CMD}"
(${CMD} 2>&1) | (2>&1 ./tqdm-batch.py --total ${NUM_FILES} --miniters 10000 --ncols 70 >/dev/null | tee -a ${LOG_FILE})
elif [[ $2 == "local-nolog" ]]; then
echo "${CMD}"
(${CMD} 2>&1) | (2>&1 ./tqdm-batch.py --total ${NUM_FILES} --miniters 10000 --ncols 70 >/dev/null)
else
bsub -n ${SLOTS} -N -o ${LOG_FILE} $0 ${BUCKET_NAME} local-nolog
fi