• Announcements

    • PaulOBrien

      Reminder - MoDaCo position on illegal content   07/30/15

      ILLEGAL CONTENT I'd like to just reaffirm MoDaCo's position regarding piracy and illegal content in the light of some recent questions / postings. Posts will be censored by myself or my moderation team if the contain or link to: Illegal / pirated / cracked software or sites that host such software Nintendo emulators / ROMs or sites hosting them (in light of Nintendo's legal stance) CUSTOM ROMS You may discuss and post links to custom device ROMs on MoDaCo, provided the following rules are adhered to: ROMs must not contain any illegal 3rd party software (this includes trial versions included without permission) ROMs must give full credit to the original author ISSUES If you have any issues with this policy, please contact PaulOBrien directly via PM.
    • PaulOBrien

      Reminder: Selling items on the forum directly is not allowed   07/30/15

      Please note that selling items on the forum directly is not allowed by the forum rules. There is a forum for eBay auctions whereby you can list the items on eBay and link to them there. This is the ONLY forum for this type of activity. You may also advertise links to the eBay forum in your signature. Please note that selling directly in contravention of these rules will result in a warning / suspension / ban.
Sign in to follow this  
Followers 0

Simple photo & video backup bash script for OTG flash media (rsync) needs root

1 post in this topic

Here's a simple bash script I've just written which, when executed via "Terminal Emulator" (or adb shell), backs up ALL Photos and videos found under /sdcard/DCIM to an inserted OTG USB flash drive/SD card reader etc.

1/ Download zip file


2/ Extract it


3/ Go into extracted DIR, and (in Windows) shift & right-click >> "Open command window here"


4/ Connect to your Moto G using ADB or ADB WiFi etc


5/ Run these commands in the command window which just opened  - YOU NEED Moto G ADB drivers and ADB installed (press enter at the end of each line, run one line at a time, in order, starting at the top line):

adb push rsync /sdcard/rsync
adb push picsync /sdcard/picsync
adb shell
mount -o remount rw /system
cp /sdcard/rsync /system/bin
cp /sdcard/picsync /system/bin
chmod 755 /system/bin/rsync
chmod 755 /system/bin/picsync
mount -o remount r /system

6/ Create a folder named "Camera" in the flash drive/SD card you wish to use to backup your photos & videos to, otherwise the script won't work.


7/ Plug in the flash drive etc to the micro USB port at the base of the Moto G

8/ Once it's mounted (give it 15 secs to be sure), open a terminal emulator and run as root:



Your photos and videos will proceed to be backed up to the "Camera" folder you created on the external media. This script will backup ALL media the first time around, and from then on, ONLY backup photos and videos that have been captured since the last time you backed up, instead of re-copying EVERYTHING again each time (which would be nuts!).

I hope you enjoy this script. I cannot offer any tech support of any kind, and please use at your own risk (there is no risk - see the source below):

if [ -d "/mnt/media_rw/usbdisk/Camera" ]; then
echo "Syncing media now..."
rsync -av --ignore-existing /sdcard/DCIM/Camera /mnt/media_rw/usbdisk/
echo "Please insert the backup drive, then run this script"

I happen to know this technique also works over ssh via WiFi to a server, as I backup this way too. However, I wanted to make this as newcomer friendly as possible, so didn't over-complicate things by adding that in also. Feel free to modify this and hack away as much as you wish :)

You may see some error messages right at the end; I think this is to do with it not being able to copy thumbnails or some kind of hidden files, but ALL photos and videos copy perfectly. If I get time and I find out how to fix that, I shall do.



Thank you :)





Edited by glossywhite

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0

MoDaCo is part of the MoDaCo.network, © Paul O'Brien 2002-2016. MoDaCo uses IntelliTxt technology.