├── README.md ├── bookmark.txt ├── gclone ├── rc.conf └── setup.sh /README.md: -------------------------------------------------------------------------------- 1 | # easyclone 2 | This is just a bash script which aims to ease the process of cloning , moving and syncing and other rclone operations. 3 | The script uses gclone to bypass the 750GB daily limit by google present in rclone by rotating the service accounts 4 | 5 | # Features 6 | * Easy one command installation from scratch does everything 7 | * Linux , Android (Termux) & Windows (Wsl/Wsl2) supported 8 | * Dynamic generation of rclone config before each operation so no need to create any config manually 9 | * Ability to use bookmark for frequently used folder_ids for convenience 10 | * Easy one word execution to invoke script 11 | 12 | # How to install / update 13 | ```bash 14 | curl -fsSkL http://tiny.cc/easyclone | bash 15 | ``` 16 | 17 | Installation is as easy as just running the above command . It will setup everything from scratch . Accordingly run it at a later stage to update script and binaries as and when needed. 18 | Proceeding installation, just enter ```clone``` whenever you need to execute the script henceforth 19 | 20 | # Pre Requisites 21 | * Generate the service accounts and have them downloaded in a folder named accounts. Follow steps from [here](https://github.com/smartass08/Service-Accounts-to-Google-groups/blob/master/README.md) if you don't have service accounts yet. 22 | * Create a new repository named accounts in your github account and upload all the service accounts json files directly in that repo 23 | 24 | # Credits 25 | * [rclone](https://github.com/rclone/rclone) 26 | * [gclone](https://github.com/donwa/gclone) 27 | * [l3v11](https://github.com/l3v11) 28 | -------------------------------------------------------------------------------- /bookmark.txt: -------------------------------------------------------------------------------- 1 | # Add all folderid here in below format , Assign each folderid any Name for easy identification 2 | Name FolderID1 // Movie 13DHPC08Fv9teB_e1ApW9Xf6ArFVBPQoR 3 | Name2 FolderID2 // Anime 13DHPC08Fv9teB_e1ApW9Xf6ArFVHJKIO 4 | # Delete all these lines, Add yours from Line 1 5 | -------------------------------------------------------------------------------- /gclone: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #============================================================= 3 | # https://github.com/xd003/clone 4 | # File Name: clone 5 | # Author: xd003 6 | # Description: Clone bash script to be used for common fclone/gclone operations 7 | # System Supported: Arch , Ubuntu/Debian , Fedora & Termux ( amd64 & arm64 ) 8 | #============================================================= 9 | 10 | cecho() { 11 | local code="\033[" 12 | case "$1" in 13 | black | bk) color="${code}0;30m" ;; 14 | red | r) color="${code}1;31m" ;; 15 | green | g) color="${code}1;32m" ;; 16 | yellow | y) color="${code}1;33m" ;; 17 | blue | b) color="${code}1;34m" ;; 18 | purple | p) color="${code}1;35m" ;; 19 | cyan | c) color="${code}1;36m" ;; 20 | gray | gr) color="${code}0;37m" ;; 21 | *) local text="$1" ;; 22 | esac 23 | [ -z "$text" ] && local text="$color$2${code}0m" 24 | echo -e "$text" 25 | } 26 | 27 | # Variable 28 | conf="$HOME/easyclone/rc.conf" 29 | ehome="$(echo $HOME)" 30 | uflags="--fast-list --drive-server-side-across-configs --drive-acknowledge-abuse --drive-keep-revision-forever --stats=10s -vP --drive-use-trash=false --drive-stop-on-upload-limit --user-agent randomstringxyz --log-file $HOME/easyclone/log.txt" 31 | jc="$(ls -l $HOME/easyclone/accounts | egrep -c '^-')" 32 | rjc1="$(shuf -i 1-$jc -n 1)" 33 | rjc2="$(shuf -i 1-$jc -n 1)" 34 | 35 | # Functions 36 | fsrc() { 37 | : > $HOME/easyclone/log.txt 38 | sed -i '/^team_drive/d' $conf 39 | sed -i '/^root_folder_id/d' $conf 40 | cecho b "[When you need to enter folder id/url , you can enter b to choose a folder id from your bookmark.txt]" 41 | read -e -p "Enter the source folder id or url : " src 42 | if [ "$src" == "b" ]; then 43 | cat $HOME/easyclone/bookmark.txt | nl -w1 -s'• ' 44 | echo 45 | read -e -p "Enter the number corresponding to the folder_id which you want to use : " NUM 46 | src="$(cat $HOME/easyclone/bookmark.txt | awk 'NF>1{print $NF}' | sed "${NUM}q;d")" 47 | else 48 | src=$(echo $src | sed -E 's~.*[/=]([01A-Z][-_[:alnum:]]+)([?/].*|$)~\1~') 49 | fi 50 | case $src in 51 | 0*) 52 | sed -i "4iteam_drive = $src" $conf 53 | ;; 54 | 1*) 55 | sed -i "4iroot_folder_id = $src" $conf 56 | ;; 57 | esac 58 | sed -ri "5s/[[:digit:]]+.json/$rjc1.json/" $conf 59 | } 60 | 61 | fdst() { 62 | read -e -p "Enter the destination folder id or url : " dst 63 | if [ "$dst" == "b" ]; then 64 | cat $HOME/easyclone/bookmark.txt | nl -w1 -s'• ' 65 | echo 66 | read -e -p "Enter the number corresponding to the folder_id which you want to use : " NUM 67 | dst="$(cat $HOME/easyclone/bookmark.txt | awk 'NF>1{print $NF}' | sed "${NUM}q;d")" 68 | else 69 | dst=$(echo $dst | sed -E 's~.*[/=]([01A-Z][-_[:alnum:]]+)([?/].*|$)~\1~') 70 | fi 71 | case $dst in 72 | 0*) 73 | sed -i "11iteam_drive = $dst" $conf 74 | ;; 75 | 1*) 76 | sed -i "11iroot_folder_id = $dst" $conf 77 | ;; 78 | esac 79 | sed -ri "12s/[[:digit:]]+.json/$rjc2.json/" $conf 80 | } 81 | 82 | while true; do 83 | cat << EOF 84 | ┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 85 | ┋1) Copy 86 | ┋ (Copy files from source to dest, skipping already copied) 87 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 88 | ┋2) Move 89 | ┋ (Move files from source to dest, skipping already moved) 90 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 91 | ┋3) Sync 92 | ┋ (Make source and dest identical, modifying destination only) 93 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 94 | ┋4) Dedupe 95 | ┋ (Find duplicate files and delete/rename them) 96 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 97 | ┋5) Size 98 | ┋ (Return the total size and number of objects) 99 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 100 | ┋6) Listing 101 | ┋ (List all the files and folders) 102 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 103 | ┋7) NCDU 104 | ┋ (Explore directory with text based UI) 105 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 106 | ┋8) Upload | Download 107 | ┋ (Move , Copy or Sync Local Folder to Drive OR Download files locally) 108 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 109 | ┋9) Empty Trash 110 | ┋ (You need to have Manager Permission in TD) 111 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 112 | ┋10) Delete Empty Folders 113 | ┋ (Delete all Empty Folders recursively) 114 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 115 | ┋11) Check 116 | ┋ (Check if the files in the source and destination match) 117 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 118 | ┋12) Delete 119 | ┋ (Delete a file or a folder along with its content) 120 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 121 | ┋13) Quit 122 | ┋ (Exit the Script) 123 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 124 | EOF 125 | 126 | echo 127 | read -e -p "Enter your input : " opt 128 | echo 129 | case $opt in 130 | 1) 131 | cecho y "Copy option has been selected" 132 | fsrc 133 | fdst 134 | echo 135 | cecho b "Do you want to use --ignore-existing flag for this process ?" 136 | cecho b "[Only use it if your source/destination doesn't contain modification of any file overwritten with same name as even after having different size they will be considered equal and ignored]" 137 | read -e -p "Enter Your Input [y/n] : " ig 138 | case $ig in 139 | [Yy]*) 140 | gclone --config=$conf copy src: dst: $uflags --ignore-existing 141 | ;; 142 | [Nn]*) 143 | gclone --config=$conf copy src: dst: $uflags 144 | ;; 145 | esac 146 | ;; 147 | 2) 148 | cecho y "Move option has been selected" 149 | fsrc 150 | fdst 151 | echo 152 | cecho b "Do you want to use --ignore-existing flag for this process ?" 153 | cecho b "[Only use it if your source/destination doesn't contain modification of any file overwritten with same name as even after having different size they will be considered equal and ignored]" 154 | read -e -p "Enter Your Input [y/n] : " ig 155 | case $ig in 156 | [Yy]*) 157 | gclone --config=$conf move src: dst: $uflags --delete-empty-src-dirs --ignore-existing 158 | ;; 159 | [Nn]*) 160 | gclone --config=$conf move src: dst: $uflags --delete-empty-src-dirs 161 | ;; 162 | esac 163 | ;; 164 | 3) 165 | cecho y "Sync option has been selected" 166 | fsrc 167 | fdst 168 | echo 169 | cecho b "Do you want to use --ignore-existing flag for this process ?" 170 | cecho b "[Only use it if your source/destination doesn't contain modification of any file overwritten with same name as even after having different size they will be considered equal and ignored]" 171 | read -e -p "Enter Your Input [y/n] : " ig 172 | case $ig in 173 | [Yy]*) 174 | gclone --config=$conf sync src: dst: $uflags --ignore-existing 175 | ;; 176 | [Nn]*) 177 | gclone --config=$conf sync src: dst: $uflags 178 | ;; 179 | esac 180 | ;; 181 | 4) 182 | cecho y "Dedupe option has been selected" 183 | cat << EOF 184 | ┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 185 | ┋1) Interactive 186 | ┋ (Use Dedupe Interactively) 187 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 188 | ┋2) Skip 189 | ┋ (Removes identical files then skips anything left) 190 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 191 | ┋3) First 192 | ┋ (Removes identical files then keeps the first one) 193 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 194 | ┋4) Newest 195 | ┋ (Removes identical files then keeps the newest one) 196 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 197 | ┋5) Oldest 198 | ┋ (removes identical files then keeps the oldest one) 199 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 200 | ┋6) Largest 201 | ┋ (removes identical files then keeps the largest one) 202 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 203 | ┋7) Smallest 204 | ┋ (removes identical files then keeps the smallest one) 205 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 206 | ┋8) Rename 207 | ┋ (removes identical files then renames the rest to be different) 208 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 209 | ┋9) Return to Main Menu 210 | ┋ (Restart the script from Main Menu) 211 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 212 | EOF 213 | echo 214 | read -e -p "Enter the Dedupe Operation Mode (1-9) : " dm 215 | if [[ $dm -ne 9 ]]; then 216 | fsrc 217 | fi 218 | case $dm in 219 | 1) 220 | cecho b "Dedupe Interactive option has been selected" 221 | gclone --config=$conf dedupe --dedupe-mode interactive src: --fast-list --verbose=2 222 | ;; 223 | 2) 224 | cecho b "Dedupe Skip option has been selected" 225 | gclone --config=$conf dedupe --dedupe-mode skip src: --fast-list --verbose=2 226 | ;; 227 | 3) 228 | cecho b "Dedupe First option has been selected" 229 | gclone --config=$conf dedupe --dedupe-mode first src: --fast-list --verbose=2 230 | ;; 231 | 4) 232 | cecho b "Dedupe Newest option has been selected" 233 | gclone --config=$conf dedupe --dedupe-mode newest src: --fast-list --verbose=2 234 | ;; 235 | 5) 236 | cecho b "Dedupe Oldest option has been selected" 237 | gclone --config=$conf dedupe --dedupe-mode oldest src: --fast-list --verbose=2 238 | ;; 239 | 6) 240 | cecho b "Dedupe Largest option has been selected" 241 | gclone --config=$conf dedupe --dedupe-mode largest src: --fast-list --verbose=2 242 | ;; 243 | 7) 244 | cecho b "Dedupe Smallest option has been selected" 245 | gclone --config=$conf dedupe --dedupe-mode smallest src: --fast-list --verbose=2 246 | ;; 247 | 8) 248 | cecho b "Dedupe Rename option has been selected" 249 | gclone --config=$conf dedupe --dedupe-mode rename src: --fast-list --verbose=2 250 | ;; 251 | 9) 252 | continue 253 | ;; 254 | esac 255 | 256 | ;; 257 | 5) 258 | cecho y "Size option has been selected" 259 | fsrc 260 | gclone --config=$conf size src: --fast-list 261 | ;; 262 | 6) 263 | cecho y "Listing option has been selected" 264 | cat << EOF 265 | ┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 266 | ┋1) ls 267 | ┋ (List the objects in the path with size and path) 268 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 269 | ┋2) lsd 270 | ┋ (List all directories/containers/buckets in the path) 271 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 272 | ┋3) lsf 273 | ┋ (List directories and objects in remote:path formatted for parsing) 274 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 275 | ┋4) lsjson 276 | ┋ (List directories and objects in the path in JSON format) 277 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 278 | ┋5) lsl 279 | ┋ (List the objects in path with modification time, size and path) 280 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 281 | ┋6) tree 282 | ┋ (List the contents of the remote in a tree like fashion) 283 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 284 | ┋7) Return to Main Menu 285 | ┋ (Restart the script from Main Menu) 286 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 287 | EOF 288 | echo 289 | read -e -p "Choose the listing type : " lt 290 | if [[ $lt -ne 7 ]]; then 291 | fsrc 292 | fi 293 | case $lt in 294 | 1) 295 | cecho b "Listing / ls option has been selected" 296 | gclone --config=$conf ls src: 297 | ;; 298 | 2) 299 | cecho b "Listing / lsd option has been selected" 300 | gclone --config=$conf lsd src: 301 | ;; 302 | 3) 303 | cecho b "Listing / lsf option has been selected" 304 | gclone --config=$conf lsf src: 305 | ;; 306 | 4) 307 | cecho b "Listing / lsjson option has been selected" 308 | gclone --config=$conf lsjson src: 309 | ;; 310 | 5) 311 | cecho b "Listing / lsl option has been selected" 312 | gclone --config=$conf lsl src: 313 | ;; 314 | 6) 315 | cecho b "Listing / tree option has been selected" 316 | gclone --config=$conf tree src: 317 | ;; 318 | 7) 319 | continue 320 | ;; 321 | esac 322 | ;; 323 | 7) 324 | cecho y "NCDU option has been selected" 325 | fsrc 326 | gclone --config=$conf ncdu src: --fast-list 2>/dev/null 327 | ;; 328 | 8) 329 | cecho y "Upload | Download option has been selected" 330 | cat << EOF 331 | ┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 332 | ┋1) Upload + Copy 333 | ┋ (Copy file/folder locally to drive, skipping already copied) 334 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 335 | ┋2) Upload + Move 336 | ┋ (Move file/folder locally to drive, skipping already moved) 337 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 338 | ┋3) Upload + Sync 339 | ┋ (Make local and drive file/folder identical, modifying drive only) 340 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 341 | ┋4) Download 342 | ┋ (Download content locally from Google Drive) 343 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 344 | ┋5) Return to Main Menu 345 | ┋ (Restart the script from Main Menu) 346 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 347 | EOF 348 | echo 349 | read -e -p "Choose the appropriate option : " upl 350 | if [[ $upl -ne 4 ]] && [[ $upl -ne 5 ]] ; then 351 | read -e -p "Enter the path of the folder which you want to upload : " src 352 | src="$(eval echo "$src")" 353 | : > $HOME/easyclone/log.txt && sed -i '/^team_drive/d' $conf && sed -i '/^root_folder_id/d' $conf && fdst 354 | fi 355 | 356 | if [ "$upl" == "4" ] ; then 357 | fsrc 358 | read -e -p "Enter the path where you want to download files locally : " dst 359 | dst="$(eval echo "$dst")" 360 | fi 361 | case $upl in 362 | 1) 363 | gclone --config=$conf copy "$src" dst: $uflags 364 | ;; 365 | 2) 366 | gclone --config=$conf move "$src" dst: $uflags --delete-empty-src-dirs 367 | ;; 368 | 3) 369 | gclone --config=$conf sync "$src" dst: $uflags 370 | ;; 371 | 4) 372 | gclone --config=$conf copy src: "$dst" $uflags 373 | ;; 374 | 5) 375 | continue 376 | ;; 377 | esac 378 | ;; 379 | 9) 380 | cecho y "Empty Trash option has been selected" 381 | fsrc 382 | gclone --config=$conf delete src: --drive-trashed-only=true --drive-use-trash=false --fast-list --verbose=2 --log-file $HOME/easyclone/log.txt 383 | ;; 384 | 10) 385 | cecho y "Delete Empty folders option has been selected" 386 | fsrc 387 | gclone --config=$conf rmdirs src: --leave-root --fast-list --log-file $HOME/easyclone/log.txt 388 | ;; 389 | 11) 390 | cecho y "Check option has been selected" 391 | cat << EOF 392 | ┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 393 | ┋1) Compare only Size 394 | ┋ (MD5/SHA1 is not considered here. Use this for a quick check) 395 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 396 | ┋2) Compare Size + MD5 / SHA1 Hash 397 | ┋ (Compares sizes and hashes and logs report of unmatched files. Very slow process) 398 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 399 | ┋3) Compare after Downloading data locally 400 | ┋ (Download data from both the directories and Compare them on the fly. Use only if remote doesn't support hashes) 401 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 402 | ┋4) Return to Main Menu 403 | ┋ (Restart the script from Main Menu) 404 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 405 | EOF 406 | echo 407 | read -e -p "Choose the Comparison Mode : " opt 408 | if [[ $opt -ne 4 ]]; then 409 | fsrc 410 | fdst 411 | fi 412 | case $opt in 413 | 1) 414 | cecho b "Check / Compare only size option has been selected" 415 | gclone --config=$conf check src: dst: -P --drive-server-side-across-configs --fast-list --size-only 416 | ;; 417 | 2) 418 | cecho b "Check / Compare size + MD5 option has been selected" 419 | gclone --config=$conf check src: dst: -P --drive-server-side-across-configs --fast-list 420 | ;; 421 | 3) 422 | cecho b "Check / Compare locally downloaded date option has been selected" 423 | gclone --config=$conf check src: dst: -P --drive-server-side-across-configs --fast-list --download 424 | ;; 425 | 4) 426 | continue 427 | ;; 428 | esac 429 | ;; 430 | 12) 431 | cecho y "Delete option has been selected" 432 | cat << EOF 433 | ┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 434 | ┋1) Delete 435 | ┋ (Delete the contents of path) 436 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 437 | ┋2) Deletefile 438 | ┋ (Delete a single file from path) 439 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 440 | ┋3) Purge 441 | ┋ (Delete the path and its content) 442 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 443 | ┋4) Return to Main Menu 444 | ┋ (Restart the script from Main Menu) 445 | ┋┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ 446 | EOF 447 | echo 448 | read -e -p "Enter your input : " opt 449 | if [[ $opt -ne 4 ]]; then 450 | fsrc 451 | fi 452 | case $opt in 453 | 1) 454 | cecho b "Delete / Default option has been selected" 455 | gclone --config=$conf delete src: -vP --stats-one-line --stats=15s --fast-list --log-file $HOME/easyclone/log.txt 456 | ;; 457 | 2) 458 | cecho b "Delete / Deletet option has been selected" 459 | gclone --config=$conf deletefile src: -vP --stats-one-line --stats=15s --fast-list --log-file $HOME/easyclone/log.txt 460 | ;; 461 | 3) 462 | cecho b "Delete / Purge option has been selected" 463 | gclone --config=$conf purge src: -vP --stats-one-line --stats=15s --fast-list --log-file $HOME/easyclone/log.txt 464 | ;; 465 | 4) 466 | continue 467 | ;; 468 | esac 469 | ;; 470 | 13) 471 | exit 472 | ;; 473 | esac 474 | if [[ "$?" ]]; then 475 | break 476 | fi 477 | done 478 | -------------------------------------------------------------------------------- /rc.conf: -------------------------------------------------------------------------------- 1 | [src] 2 | type = drive 3 | scope = drive 4 | service_account_file = HOME/easyclone/accounts/1.json 5 | service_account_file_path = HOME/easyclone/accounts/ 6 | 7 | [dst] 8 | type = drive 9 | scope = drive 10 | service_account_file = HOME/easyclone/accounts/1.json 11 | service_account_file_path = HOME/easyclone/accounts/ 12 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #============================================================= 3 | # https://github.com/xd003/clone 4 | # File Name: setup.sh 5 | # Author: xd003 6 | # Description: Installing prerequisites for clone script 7 | # System Supported: Arch , Ubuntu/Debian , Fedora & Termux 8 | #============================================================= 9 | 10 | function cleanup { 11 | echo "Deleting all directories and binaries" 12 | ehome="$(echo $HOME)" 13 | rm -rf $HOME/tmp 14 | rm -rf $HOME/easyclone 15 | if [ "$ehome" == "/data/data/com.termux/files/home" ]; then 16 | rm -rf $(command -v clone) &>/dev/null 17 | else 18 | sudo rm -rf $(command -v clone) &>/dev/null 19 | fi 20 | exit 21 | } 22 | trap cleanup INT 23 | 24 | cecho() { 25 | local code="\033[" 26 | case "$1" in 27 | black | bk) color="${code}0;30m";; 28 | red | r) color="${code}1;31m";; 29 | green | g) color="${code}1;32m";; 30 | yellow | y) color="${code}1;33m";; 31 | blue | b) color="${code}1;34m";; 32 | purple | p) color="${code}1;35m";; 33 | cyan | c) color="${code}1;36m";; 34 | gray | gr) color="${code}0;37m";; 35 | *) local text="$1" 36 | esac 37 | [ -z "$text" ] && local text="$color$2${code}0m" 38 | echo -e "$text" 39 | } 40 | 41 | banner () { 42 | clear 43 | cat << EOF 44 | ╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╭╮ 45 | ┃╭━━╯╱╱╱╱╱╱╱╱╱╱╱╱┃┃ 46 | ┃╰━━┳━━┳━━┳╮╱╭┳━━┫┃╭━━┳━╮╭━━╮ 47 | ┃╭━━┫╭╮┃━━┫┃╱┃┃╭━┫┃┃╭╮┃╭╮┫┃━┫ 48 | ┃╰━━┫╭╮┣━━┃╰━╯┃╰━┫╰┫╰╯┃┃┃┃┃━┫ 49 | ╰━━━┻╯╰┻━━┻━╮╭┻━━┻━┻━━┻╯╰┻━━╯ 50 | ╱╱╱╱╱╱╱╱╱╱╭━╯┃ 51 | ╱╱╱╱╱╱╱╱╱╱╰━━╯ 52 | EOF 53 | } 54 | banner 55 | 56 | #Variables 57 | arch="$(uname -m)" 58 | ehome="$(echo $HOME)" 59 | epac="$(command -v pacman 2>/dev/null)" 60 | eapt="$(command -v apt 2>/dev/null)" 61 | ednf="$(command -v dnf 2>/dev/null)" 62 | conf="$HOME/easyclone/rc.conf" 63 | 64 | # Detecting the OS and installing required dependencies 65 | echo 66 | if [ "$ehome" == "/data/data/com.termux/files/home" ]; then 67 | cecho g "¶ Termux detected | Installing required packages" && \ 68 | pkg update && pkg install -y unzip git wget tsu python tmux &>/dev/null 69 | if [ ! -d ~/storage ]; then 70 | cecho r "Setting up storage access for Termux" 71 | termux-setup-storage 72 | sleep 2 73 | fi 74 | elif [ "$epac" == "/usr/bin/pacman" ]; then 75 | cecho g "¶ Arch based OS detected | Installing required packages" && \ 76 | sudo pacman -Syy && sudo pacman --noconfirm -S unzip git wget python tmux 77 | elif [ "$eapt" == "/usr/bin/apt" ]; then 78 | cecho g "¶ Ubuntu based OS detected | Installing required packages" && \ 79 | sudo apt update && sudo apt install -y unzip git wget python3 tmux 80 | elif [ "$ednf" == "/usr/bin/dnf" ]; then 81 | cecho g "¶ Fedora based OS detected | Installing required packages" 82 | sudo dnf check-update && sudo dnf install -y unzip git wget python3 tmux 83 | fi 84 | 85 | # Detecting Source path for binaries and script to be added 86 | spath="$(command -v git)" 87 | spath=$(echo $spath | sed 's/\/git$//') 88 | 89 | # Downloading latest easyclone script from github 90 | cecho g "¶ Downloading latest easyclone script from github" 91 | if [ "$ehome" == "/data/data/com.termux/files/home" ]; then 92 | rm -rf $(command -v clone) &>/dev/null 93 | else 94 | sudo rm -rf $(command -v clone) &>/dev/null 95 | fi 96 | rm -rf $HOME/tmp 97 | mkdir $HOME/tmp 98 | git clone https://github.com/xd003/easyclone $HOME/tmp &>/dev/null 99 | mkdir -p $HOME/easyclone 100 | mv $HOME/tmp/gclone $HOME/easyclone 101 | 102 | find $HOME/easyclone -type d -empty -delete 103 | cecho g "¶ Pulling the accounts folder containing service accounts from github" 104 | if [ ! -d "$HOME/easyclone/accounts" ]; then 105 | mkdir -p $HOME/easyclone/accounts 106 | read -e -p "Input your github username : " username 107 | echo && echo "If you dont have a personal access token , you can generate one following this guide - https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token" 108 | echo && read -e -p "Input your github's personal access token : " password 109 | while ! git clone https://"$username":"$password"@github.com/"$username"/accounts $HOME/easyclone/accounts; do 110 | cecho r 'Invalid username or password, please retry' >&2; 111 | read -e -p "Input your github username : " username 112 | read -e -p "Input your github's personal access token : " password 113 | done 114 | fi 115 | 116 | cecho g "¶ Renaming the json files in numerical order" 117 | rm -rf $HOME/easyclone/accounts/.git 118 | if [ ! -f "$HOME/easyclone/accounts/5.json" ] ; then 119 | (cd $HOME/easyclone/accounts; ls -v | cat -n | while read n f; do mv -n "$f" "$n.json"; done) 120 | elif [ ! -f "$HOME/easyclone/accounts/10.json" ] ; then 121 | (cd $HOME/easyclone/accounts; ls -v | cat -n | while read n f; do mv -n "$f" "$n.json"; done) 122 | elif [ ! -f "$HOME/easyclone/accounts/15.json" ] ; then 123 | (cd $HOME/easyclone/accounts; ls -v | cat -n | while read n f; do mv -n "$f" "$n.json"; done) 124 | fi 125 | 126 | 127 | # Moving gclone Config file & bookmark.txt to easyclone folder 128 | cecho g "¶ Moving the config file to easyclone folder" 129 | rm -rf $HOME/easyclone/rc.conf 130 | mv $HOME/tmp/rc.conf $HOME/easyclone 131 | if [ ! -f "$HOME/easyclone/bookmark.txt" ] ; then 132 | mv $HOME/tmp/bookmark.txt $HOME/easyclone 133 | fi 134 | sed -i "s|HOME|$ehome|g" $conf 135 | 136 | gcloneinstall() { 137 | if [ "$arch" == "x86_64" ] ; then 138 | arch=amd64 139 | fi 140 | 141 | cecho g "¶ Downloading and adding gclone to path" 142 | egclone="$(gclone version 2>/dev/null)" 143 | check="$(echo "$egclone" | grep 'v1\.62\.2')" 144 | if [ -z "${check}" ] ; then 145 | gclone_version="v1.62.2-purple" 146 | if [ "$arch" == "aarch64" ] ; then 147 | URL=https://github.com/xd003/files/raw/main/gclone%20v1.62.2.zip 148 | else 149 | URL=https://github.com/l3v11/gclone/releases/download/$gclone_version/gclone-$gclone_version-linux-$arch.zip 150 | fi 151 | wget -c -t 0 --timeout=60 --waitretry=60 $URL -O $HOME/tmp/gclone.zip &>/dev/null && 152 | unzip -q $HOME/tmp/gclone.zip -d $HOME/tmp &>/dev/null && 153 | if [ "$ehome" == "/data/data/com.termux/files/home" ]; then 154 | mv $HOME/tmp/gclone $spath 155 | chmod u+x $spath/gclone 156 | else 157 | sudo mv $HOME/tmp/gclone-$gclone_version-linux-$arch/gclone $spath 158 | sudo chmod u+x $spath/gclone 159 | fi 160 | fi 161 | } 162 | 163 | gcloneinstall 164 | 165 | #################################################################### 166 | 167 | echo 168 | cecho g "¶ Creating Symlink for clone script in path" 169 | if [ "$ehome" == "/data/data/com.termux/files/home" ]; then 170 | ln -sf "$HOME/easyclone/gclone" "$spath/clone" 171 | chmod u+x $spath/clone 172 | else 173 | sudo ln -sf "$HOME/easyclone/gclone" "$spath/clone" 174 | sudo chmod u+x $spath/clone 175 | fi 176 | 177 | # Shorten Expanded Variable 178 | if [ "$ehome" == "/data/data/com.termux/files/home" ]; then 179 | sed -i "s|--config=$HOME/easyclone/rc.conf|--config=$conf|g" $(command -v clone) 180 | else 181 | sudo sed -i "s|--config=$HOME/easyclone/rc.conf|--config=$conf|g" $(command -v clone) 182 | fi 183 | 184 | rm -rf $HOME/tmp 185 | cecho g "¶ Installation 100% successful" 186 | echo 187 | cecho g "✓ Entering clone will always start the script henceforth" 188 | --------------------------------------------------------------------------------