Android: Using Tasker to backup photos to OneDrive
I have for the longest time used QuickPic to backup the photos on my mobile device (in addition to viewing photos). Until recently this has worked out well, but as the app is no longer reliable I had to search for another setup. After searching around for a longest while I was unable to find any application that fulfilled my requirements, thus I setup my own solution using Tasker and OneSync.
The setup I am using now and describing below works with any other cloud/network backup solution, in that case OneSync can be replaced with another app of your choice.
- Most backup solutions have possibility for one-way sync with deletion, i.e. copy the source file to destination and remove the original source file.
- Local copy
- Tasker will monitor folders where new photos (or other files for that matter) are created.
- Upon creation of a new file Tasker will copy the file to a pre-set destination folder.
- Remote copy
The pre-set folder is monitored for changes by the cloud backup solution, or Tasker may trigger an upload action.
- The cloud backup solution will copy the file from the local source folder to destination cloud folder
- The local source file will be removed.
Let us start with the remote copy setup first.
I will be using the OneSync software to backup to OneDrive, but similar technique applies for other destinations.
Start by installing OneSync.
Connect OneSync to you OneDrive
When OneSync is connected, set up a folder pair to sync. I use the following settings:
Remote folder: /Picture/Camera Roll Local folder: /storage/emulated/0/DCIM/Uploads Sync method: Upload then delete Sync enabled: True
In the above settings, OneSync will move any files found in my local folder
/storage/emulated/0/DCIM/Uploads1 to the Camera Roll in my OneDrive
Enable your newly created folder pair under the
Enable Autosync. The sync will be triggered by Tasker, thus there is no need for an extra service running in the background.
Verify that OneSync works.
Copy a file to the local folder.
Open OneSync and press the
The file should now be copied to your camera roll
Setting up Tasker
Here we will set up two items, the task that actually copies the file and initiates the trigger and the profile which monitors the directory.
Create a new Event profile.
In the Event Edit, press the magnifying to bring up a file selector.
Navigate to the folder you wish to monitor
Long press the folder you wish to monitor.
Press the back key
Creating the task
Add an action:
Name: %dir To: %evtprm()
Variable Search Replace
Variable: %dir Search: file:// Replace Matches: True Replace With: <Empty>
Dir: %dir Sort Select: Modification Date, Reverse Variable: %files
Name: %file To: %files(1)
Variable Search Replace
Variable: %file Search: %dir Replace Matches: True Replace With: <path-to-sync-folder>
<path-to-sync-folder>above represents the folder set up earlier
From: %files(1) To: %file
Configuration: Sync Now
Now test that this works by adding a file into the monitored directory.
Google Play | Autosync OneDrive - OneSync Google Play | QuickPic - Photo Gallery with Google Drive Support Google Play | Tasker
- Of course, this can be any folder on your device. It is advised to keep this on the local SD card to avoid having to deal with permissions to external SD cards on later Android versions. [return]