7
7
. " /usr/bin/config"
8
8
# #############################################################################
9
9
10
+ oldSize=0
11
+ movedSize=0
12
+
10
13
rm_time () {
11
14
# Generate filelist and iterate through it...
12
15
find " ${local_decrypt_dir} " -type f -mtime +$REMOVE_LOCAL_FILES_AFTER_DAYS |
@@ -34,8 +37,22 @@ rm_time () {
34
37
done
35
38
36
39
# Move file to remote destination[s], retaining path
37
- echo " [ $( date $( printenv DATE_FORMAT) ) ] Moving file -> ${n} to Google Drive."
38
40
rclone move $rclone_options " $@ " " $n " " $( printenv RCLONE_CLOUD_ENDPOINT) ${destpath} " > /dev/null 2>&1
41
+
42
+ fileSize=$( du -sb " $n " | awk ' {print $1}' )
43
+ movedSize=$(( movedSize + fileSize))
44
+
45
+ sizeInMb=$(( movedSize / 1000 / 1000 ))
46
+ diffSize=$(( movedSize - oldSize))
47
+ if [[ " ${sizeInMb} " -gt 1000 ]]; then
48
+ if [[ " ${diffSize} " -gt " 1000000000" ]]; then # greater than 1 GB
49
+ oldSize=$movedSize
50
+ echo " [ $( date ${date_format} ) ] $(( sizeInMb / 1000 )) GB uploaded"
51
+ fi
52
+ elif [[ " ${diffSize} " -gt " 100000000" ]]; then # greater than 100 MB
53
+ oldSize=$movedSize
54
+ echo " [ $( date ${date_format} ) ] ${sizeInMb} MB uploaded"
55
+ fi
39
56
done
40
57
41
58
find " ${local_decrypt_dir} " -mindepth 1 -type d -empty -delete
@@ -68,8 +85,22 @@ rm_instant () {
68
85
done
69
86
70
87
# Move file to remote destination[s], retaining path
71
- echo " [ $( date $( printenv DATE_FORMAT) ) ] Moving file -> ${n} to Google Drive."
72
88
rclone move $rclone_options " $@ " " $n " " $( printenv RCLONE_CLOUD_ENDPOINT) ${destpath} " > /dev/null 2>&1
89
+
90
+ fileSize=$( du -sb " $n " | awk ' {print $1}' )
91
+ movedSize=$(( movedSize + fileSize))
92
+
93
+ sizeInMb=$(( movedSize / 1000 / 1000 ))
94
+ diffSize=$(( movedSize - oldSize))
95
+ if [[ " ${sizeInMb} " -gt 1000 ]]; then
96
+ if [[ " ${diffSize} " -gt " 1000000000" ]]; then # greater than 1 GB
97
+ oldSize=$movedSize
98
+ echo " [ $( date ${date_format} ) ] $(( sizeInMb / 1000 )) GB uploaded"
99
+ fi
100
+ elif [[ " ${diffSize} " -gt " 100000000" ]]; then # greater than 100 MB
101
+ oldSize=$movedSize
102
+ echo " [ $( date ${date_format} ) ] ${sizeInMb} MB uploaded"
103
+ fi
73
104
done
74
105
75
106
find " ${local_decrypt_dir} " -mindepth 1 -type d -empty -delete
@@ -83,13 +114,12 @@ rm_space () {
83
114
exit 02
84
115
fi
85
116
86
- addedSpace=0
87
117
freeup=$(( $FREEUP_ATLEAST_GB * 1000 * 1000 * 1000 ))
88
118
89
119
find " ${local_decrypt_dir} " -type f -print0 | xargs -0 stat --format ' %Y :%y %n' | sort -n | cut -d: -f2- | awk ' {$1=$2=$3=""; print $0}' |
90
120
while read -r n; do
91
- if [ " $addedSpace " -gt " $freeup " ]; then
92
- spaceInGb=$(( $addedSpace / 1000 / 1000 / 1000 ))
121
+ if [ " $movedSize " -gt " $freeup " ]; then
122
+ spaceInGb=$(( $movedSize / 1000 / 1000 / 1000 ))
93
123
spaceLeft=$(( $(du - sb "$local_decrypt_dir " | awk '{print $1 }') / 1000 / 1000 / 1000 ))
94
124
echo " [ $( date $( printenv DATE_FORMAT) ) ] Removed ${spaceInGb} GB. Media in total ${spaceLeft} GB."
95
125
break
@@ -116,14 +146,23 @@ rm_space () {
116
146
sleep 10
117
147
done
118
148
119
- fileSize=$( du -sb " $n " | awk ' {print $1}' )
120
- addedSpace=" $(( $addedSpace + $fileSize )) "
121
-
122
- fileSizeGb=$(( $fileSize / 1000 / 1000 / 1000 ))
123
-
124
149
# Move file to remote destination[s], retaining path
125
- echo " [ $( date $( printenv DATE_FORMAT) ) ] Moving file -> ${n} to Google Drive. Freeing up ${fileSizeGb} GB"
126
150
rclone move $rclone_options " $@ " " $n " " $( printenv RCLONE_CLOUD_ENDPOINT) ${destpath} " > /dev/null 2>&1
151
+
152
+ fileSize=$( du -sb " $n " | awk ' {print $1}' )
153
+ movedSize=$(( movedSize + fileSize))
154
+
155
+ sizeInMb=$(( movedSize / 1000 / 1000 ))
156
+ diffSize=$(( movedSize - oldSize))
157
+ if [[ " ${sizeInMb} " -gt 1000 ]]; then
158
+ if [[ " ${diffSize} " -gt " 1000000000" ]]; then # greater than 1 GB
159
+ oldSize=$movedSize
160
+ echo " [ $( date ${date_format} ) ] $(( sizeInMb / 1000 )) GB uploaded"
161
+ fi
162
+ elif [[ " ${diffSize} " -gt " 100000000" ]]; then # greater than 100 MB
163
+ oldSize=$movedSize
164
+ echo " [ $( date ${date_format} ) ] ${sizeInMb} MB uploaded"
165
+ fi
127
166
done
128
167
129
168
find " ${local_decrypt_dir} " -mindepth 1 -type d -empty -delete
0 commit comments