Code Monkey home page Code Monkey logo

android-file-sync's Introduction

Android File Sync (for Google Photos)

Automatically copy new files to an Android phone.

Motivation

Google Photos stopped providing free unlimited photo backups, but Pixel phones up to the Pixel 5 retain this benefit (and make no distinction about whether the pictures it backs up were taken using that Pixel). So, it is possible to copy your photos over to the Pixel phone for it to back up for free to Google Photos. I wrote this tool to help automate that process.

Why not rsync?

Rsync is designed to keep two directories in sync. But once Google Photos has backed up the photos, those photos no longer need to be on the phone. While you can, and should, delete the files from the phone after they've been backed up, I was unable to find a way to prevent rsync from copying those files back in.

I made this tool to bridge that gap. It will only copy new files to the phone and ignore that old files are missing from the phone.

How to Install

On your computer

Every platform is different so these instructions are only in general terms.

  1. Download the sync.py and requirements.txt files.
    • Or install git and git clone this repository.
  2. Use a Python virtual environment with pip to set up the dependencies for this tool.

On your Pixel phone

  1. Install SimpleSSHD.
    • For the computer to be able to SSH into the phone to copy the files over.
    • Set it up to accept your computer's SSH public key.
  2. Install Tasker.
    • For activating Media Scan. Android will not realize you've copied over any photos until you run a Media Scan on those files.
    • There are alternative apps specifically for doing the Media Scan, but Tasker can allow you to automate this process.
      • I want to set the Pixel phone aside and never need to touch it, so I use Tasker. You can skip Tasker if you are okay manually triggering a scan.
    • TODO - Specific instructions

How to Use

  1. Create a sync directory at the root of your phone storage (the directory that contains DCIM, Pictures, Movies, etc.).
  2. Within sync, create a directory for each source folder you want to sync. For example, if I want to sync photos from a Galaxy and an iPhone and have their photos in separate source folders, then I would create /sync/galaxy and /sync/iphone.
    • Each directory will be a separate run of this tool.
  3. Initialize the directories by copying over the oldest file you want to have synced into each respective directory.
    • The tool will read this file's modified date as the cutoff point and only copy files over that are newer than this file.
    • This file will later be deleted when the sliding window has to make space for newer files.
  4. Open the Google Photos app and turn on auto backup of your destination folders (galaxy and iphone in my example).
  5. With SimpleSSHD set up with your computer's SSH public key, let's make the following assumptions for the example command below:
    • Phone IP is 192.168.0.111.
    • SSH port is 2222 (default with SimpleSSHD).
    • Your SSH key is at ~/.ssh/id_rsa.
  6. An example command is: python sync.py --source /media/cameras/galaxy/ --destination galaxy --phone_ip 192.168.0.111 --phone_port_num 2222 --rsa ~/.ssh/id_rsa
    • This will copy any newer files from /media/cameras/galaxy on your computer to /sdcard/sync/galaxy on your Pixel phone.

Known limitations

  • I did not design this to work recursively, so only files in the provided source directory are considered.
  • It requires you to manually initialize with a starting file in the destination directory.
  • The intent of this tool is to do incremental updates, copying over new files as they become available. The tool has no special handling for massive all-at-once syncs that could exceed the phone's storage capacity.
    • If you are just starting out, I would manually handle backing up your backlog and then use this script for the incremental backups going forward.

android-file-sync's People

Contributors

nekorevend avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.