Python scripts for transferring files from an Android phone to Google Drive via PyDrive through Termux
backup-pydrive.py uploads all of the files in local_folder_path to a folder titled drive_folder_title that it creates on the Google Drive home page. It also (optionally, if enabled) moves the uploaded files to a different folder on the phone specified via final_folder_title.
- Download on Google Play Store.
- Setup access to local phone storage by executing
termux-setup-storage.- See Termux Wiki for details.
- Execute
pkg install python.
- Execute
pip install pydrive.
- Obtain a
client_secrets.jsonfile by following the instructions here. - Add your Google Account as a test user by following the instructions here.
- Modify lines
5-8ofbackup-pydrive.pyappropriately:
local_folder_path = "/data/data/com.termux/files/home/storage/dcim/Camera" # folder from which to upload
drive_folder_title = "Camera" # new folder to upload to
relocate_uploaded_files = False # set to true if you want photos to be moved to a different location after upload
final_folder_title = "../camera-roll" # where photos are moved after being uploaded (if `relocate_uploaded_files` is True)- Place the
backup-pydrive.pyscript and theclient_secrets.jsonin a desired location on the phone. - Navigate to this location and execute
python3 backup.py.