google / adb-sync

Apache License 2.0
1.08k stars 169 forks source link

How to exclude a certain folder? #25

Closed hammi1 closed 5 years ago

hammi1 commented 6 years ago

Is there a way to exclude certain folders from being transferred, in either a forward or reverse sync?

For e.g., my main conundrum is that I want to sync my phones /sdcard/ folder onto my backup drive, which would add all new pictures/videos and downloads. However, I want to exclude the /sdcard/Android/ folder which has unnecessary cache files.

Is there a way to do this, or would it be better for me to sync only the most needed folders (such as DCIM, Downloads, etc)?

Thank you

d3adb5 commented 6 years ago

Since the feature request still hasn't been taken and whatnot, you can do something like a shell loop through extended globbing.

for directory in !(UnwantedPattern); do
    adb-sync "$directory" /storage/5111-3BEE
done

This can help for forward syncs, but I don't think there's a very easy workaround for directories on your Android phone itself.

hammi1 commented 6 years ago

Thank you for that, though for the case on my system is the reverse sync to backup my Android to my HDD.

I have resorted to backing up few important folders that I need instead, using an array and a for loop to sync said folders, as shown below.

This way might actually be better, because I wouldn't need the random folders in /sdcard/ created by apps, nor the Android folder inside /sdcard/, given that it contains caches and isn't as necessary as my pictures/music/etc. I can also add into the array any other folder I want transferred

declare -a arr=("DCIM" "Downloads" "audio" "Pictures" "APK" "ZIP")

for FolderStr in "${arr[@]}"
do
        ./adb-sync/adb-sync --reverse /storage/emulated/0/$FolderStr/ /media/DATA/OP3T/sdcard/$FolderStr/
# echo "$FolderStr"
done
divVerent commented 5 years ago

Duplicate of #21.

DoctorSubtilis commented 5 years ago

Hi, @https://github.com/skewerr I tried your code

for directory in "!(-*)"; do
  adb-sync /home/schede/cultura/inglese/. sdcard/Documents/inglese/
done  

But I'm not able to sinc my folder with the tablet. I have to sync all except symlinks (folders and files). Can you help me?