master-hax / pixel-backup-gang

backup tools for OG pixel & pixel XL
44 stars 6 forks source link

Trigger Uploads #4

Open vegedb opened 3 months ago

vegedb commented 3 months ago

Problem

I find that "background uploads" is unreliable and it prevents new stuff to be transferred to the SSD since it will be full when upload doesn't happen. Since my pixel is away most of the time, its not that feasible to trigger physically.

What I've tried

1) Use https://github.com/Genymobile/scrcpy manually go to the app and force upload using desktop/laptop. (Works but Not automated) 2) Tasker + AutoInput to do the press commands (This is unreliable since the phone sometimes close tasker due to deep sleep or lack of ram?)

Question

Is there an adb command or root app to "Trigger upload"? Would be great if its adb since we can use home assistant to do it.

master-hax commented 3 months ago

try

adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://FILE_PATH

where FILE_PATH might be /sdcard/the_binding or /mnt/runtime/write/emulated/0/the_binding

not sure if you need to specify each file individually

vegedb commented 3 months ago

try


adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://FILE_PATH

IIRC this is for refreshing/scan photos app for new photos. I have no problems getting google photos app to look for new photos.

To be specific, I'm looking for a way to automate this button. image

Free Up Space

image

image

On another note, what about automation for "Free up space"? Any ideas?

master-hax commented 3 months ago

ah i see. this is a problem i have thought about before.

there may be a way to reliably automate the touch commands using either adb shell uiautomator runtest or a combination of adb shell uiautomator dump & adb shell input tap x y

vegedb commented 3 months ago

ah i see. this is a problem i have thought about before.

there may be a way to reliably automate the touch commands using either adb shell uiautomator runtest or a combination of adb shell uiautomator dump & adb shell input tap x y

Guess i'll try to figure out tasker for the time being. BTW, does 32gb model (cheaper) work for this? I've only tried 128gb. Also should we try to limit the SSD to 128gb? I see you're using 1TB, won't that flag their system?

master-hax commented 3 months ago

Yes, the 32gb model works fine.

Dunno about getting flagged by google. We aren't breaking any TOS afaik.

milchalpenl commented 3 months ago

automation for "Free up space"? Any ideas?

This is trivial. One can always do

adb shell rm -f /PATH If you delete by adb then the cloud upload is NOT deleted. Yes, it is not deleted.

"background uploads" is unreliable and it prevents new stuff to be transferred to the SSD

What prevents? can't understand. Like the other idea in comment above I have a script that does the following:

#####delete all files older then 1 week
adb shell find /PATH* -mmin +604800  -delete

for FILENAME in `find /path  -type f -iname \*.jpeg `
do
adb push SYNTAX
adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://FILE_PATH
done
master-hax commented 3 months ago

The "free up space" button provides a guarantee that the media has been successfully uploaded before being deleted.

Deleting the media manually (using rm) does not provide any such guarantees. It can & will delete media that has not been backed up.

vegedb commented 3 months ago

automation for "Free up space"? Any ideas?

This is trivial. One can always do

adb shell rm -f /PATH If you delete by adb then the cloud upload is NOT deleted. Yes, it is not deleted.

"background uploads" is unreliable and it prevents new stuff to be transferred to the SSD

What prevents? can't understand. Like the other idea in comment above I have a script that does the following:

#####delete all files older then 1 week
adb shell find /PATH* -mmin +604800  -delete

for FILENAME in `find /path  -type f -iname \*.jpeg `
do
adb push SYNTAX
adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://FILE_PATH
done

I have explained android.intent.action.MEDIA_SCANNER_SCAN_FILE purpose to "refresh" if your photos DO NOT appear on google photos. This is not the problem.

Main points if you got confused, Background upload do not INSTANTLY start if,

  1. Your phone gets locked/deep sleep for a LONG TIME (days) > doze problem
  2. Your Wifi/ethernet disconnects/reconnects for whatever reason
  3. Your USB power cuts off intermittently
  4. Your phone RAM decides to kick google photos out

All these points to unreliability of having it decide for you. Would love to have an option to have more control over initiating uploads.

Also like @master-hax said, you might delete stuff that's not backed up using this method.

milchalpenl commented 2 months ago

Main points if you got confused, Background upload do not INSTANTLY start if,

Confusion? None. PS: I have even used 2TB HDD (not SSD) still it uploads reliably. Not instantly. It perhaps takes few hours and then it starts.

Your phone gets locked/deep sleep for a LONG TIME (days) > doze problem

Never experienced it

Your Wifi/ethernet disconnects/reconnects for whatever reason

Every day at 03:00 the ISP does disconnect and reconnect but no problems

Your USB power cuts off intermittently

Never

Your phone RAM decides to kick google photos out

There is nothing running except Google Photos. Why would it?

Of course, like anything YMMV.