20
20
# Check your AWS PROFILE at ~/.aws/credentials and ~/.aws/config
21
21
# The output of rclone command should be shown in a few minuts
22
22
23
- export RCLONE_S3_PROVIDER=
23
+ export RCLONE_S3_PROFILE=
24
+ export RCLONE_S3_REGION=
25
+ export RCLONE_S3_PROVIDER=
24
26
export RCLONE_S3_ENDPOINT=
25
- export RCLONE_S3_REGION=
26
27
export RCLONE_S3_LOCATION_CONSTRAINT=
27
- export RCLONE_S3_PROFILE=
28
28
export AWS_ACCESS_KEY_ID=
29
29
export AWS_SECRET_ACCESS_KEY=
30
30
@@ -86,21 +86,22 @@ check_environment() {
86
86
87
87
if [[ -z $RCLONE_S3_REGION ]]; then
88
88
echo -e " \nWARNING: RCLONE_S3_REGION not set. Set it in the install.sh top's variables.\n"
89
+ echo -e " If your S3 provider does not need a region, you can ignore this warning.\n"
89
90
echo -e " You may get this information from the Where-did-the-files-go.txt manifest file\n"
90
91
fi
91
92
92
93
if [[ -z $RCLONE_S3_LOCATION_CONSTRAINT ]]; then
93
94
echo -e " \n WARNING: RCLONE_S3_LOCATION_CONSTRAINT not set. Set it in the install.sh top's variables.\n"
95
+ echo -e " If your S3 provider does not need a region, you can ignore this warning.\n"
94
96
echo -e " You may get this information from the Where-did-the-files-go.txt manifest file\n"
95
97
fi
96
98
97
99
if [[ -z $RCLONE_S3_PROFILE ]]; then
98
- if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY ]]; then
99
- echo -e " \nAWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY not set. Set it in the install.sh top's variables.\n"
100
- echo -e " You may get this information from the Where-did-the-files-go.txt manifest file\n"
101
- exit 1
102
- else
103
- echo -e " \nRCLONE_S3_PROFILE not set. Set it in the install.sh top's variables.\n"
100
+ if [ -z " $AWS_ACCESS_KEY_ID " ] || [ -z " $AWS_SECRET_ACCESS_KEY " ]; then
101
+ echo -e " \nRclone needs to configure one of two options:"
102
+ echo " 1) RCLONE_S3_PROFILE"
103
+ echo " 2) AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY\n"
104
+ echo -e " \nSet one of them it in the install.sh top's variables.\n"
104
105
echo -e " You may get this information from the Where-did-the-files-go.txt manifest file\n"
105
106
exit 1
106
107
fi
@@ -154,7 +155,7 @@ restore_rclone(){
154
155
echo -e " \t[-]${RCLONE_S3_PROFILE} profile not found in ~/.aws/credentials. Add credentials to restore.conf.\n"
155
156
exit 1
156
157
else
157
- echo -e " \t\t[+] Using configured AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as AWS credentials\n "
158
+ echo -e " \t\t[+] Using configured AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as AWS credentials"
158
159
fi
159
160
else
160
161
echo -e " \t\t[+] Using ~/.aws/credentials profile:${RCLONE_S3_PROFILE} "
@@ -204,10 +205,16 @@ restore_rclone(){
204
205
205
206
# Execute the restore command
206
207
rclone backend restore --max-depth=1 -o priority=Bulk -o lifetime=30 ${ARCHIVE_FOLDER} > ${RESTORE_OUTPUT}
207
-
208
+
208
209
# Get the status of each file
209
210
statuses=$( jq -r ' .[].Status' ${RESTORE_OUTPUT} )
210
211
212
+ # Check if the retrieve command failed
213
+ if [ -z " $statuses " ]; then
214
+ echo -e " \nError: Retrieve command failed. Check the configured variables at the top of the script.\n"
215
+ exit 1
216
+ fi
217
+
211
218
# Variable to store the status of the restore
212
219
all_ok=true
213
220
@@ -219,12 +226,12 @@ restore_rclone(){
219
226
fi
220
227
done
221
228
229
+
222
230
if $all_ok ; then
223
231
echo -e " \nGlacier retrieve initiated."
224
232
echo -e " Execute the same command again 48 hours after restore was initiated.\n"
225
233
exit 0
226
234
else
227
- # Retrieval already initiated
228
235
229
236
# Execute the restore-status command
230
237
rclone backend restore-status --max-depth=1 -o priority=Bulk -o lifetime=30 ${ARCHIVE_FOLDER} > ${RESTORE_STATUS_OUTPUT}
@@ -251,25 +258,25 @@ restore_rclone(){
251
258
done
252
259
253
260
if $all_true ; then
254
- echo -e " \nRetrieve : Glacier retrieve in progress, try again 48 hours after restore was initiated.\n"
261
+ echo -e " \nINFO : Glacier retrieve in progress, try again 48 hours after restore was initiated.\n"
255
262
exit 0
256
263
elif $all_false ; then
257
264
# If all files have been restored, we can proceed with the restore
258
265
# This path is the only one that goes though the restore process
259
- echo -e " \nRetrieve : Glacier retrieve finished."
266
+ echo -e " \nINFO : Glacier retrieve finished."
260
267
else
261
- echo -e " \nRetrieve : Only some files have been retrieved. Glacier retrieve in progress, try again 48 hours after restore was initiated.\n"
268
+ echo -e " \nINFO : Only some files have been retrieved. Glacier retrieve in progress, try again 48 hours after restore was initiated.\n"
262
269
exit 0
263
270
fi
264
271
fi
265
272
fi
266
273
267
274
# ## Restoring from S3 to local folder
268
- echo " Restoring from ${ARCHIVE_FOLDER} to ${DIRECTORY_PATH} ..."
275
+ echo -e " \nRestoring from ${ARCHIVE_FOLDER} to ${DIRECTORY_PATH} ..."
269
276
rclone copy --checksum --progress --verbose ${ARCHIVE_FOLDER} ${DIRECTORY_PATH} ${DEPTH}
270
277
271
278
# ## Comparing S3 with local folder
272
- echo " Running Checksum comparison, hit ctrl+c to cancel ... "
279
+ echo -e " \nRunning Checksum comparison, hit ctrl+c to cancel ... "
273
280
rclone check --verbose --exclude=' .froster.md5sum' ${ARCHIVE_FOLDER} ${DIRECTORY_PATH} ${DEPTH}
274
281
275
282
# ## After restore we must check if there are any files to untar
0 commit comments