Request - Copy or Mirror /sdcard to /sdcard2

Search This thread

long_tall_texan

Senior Member
Feb 24, 2011
258
68
DFW, TX
OK. I do this all the time on my Win PC. I am just not savvy enough in android/terminal to know how to do this. Is it possible to copy everything on the internal phone memory /sdcard to a sub-folder on my 32 GB microSD card /sdcard2. Ideally, I would like to do something like using robocopy /sdcard /sdcard2/sdcard /mir on a pc. But have it done straight from my phone rather than manually in sync mode via USB. And in addition, it would be really nice to only copy new/modified files. Oh, and one last request... Can it be set to run automatically every night while I sleep?

I figure this should be a simple task for one of you devs, or maybe there is already an app that does this.
 

long_tall_texan

Senior Member
Feb 24, 2011
258
68
DFW, TX
After thinking about this, I guess it would not be ADB commands, it would be Linux shell / Busybox commands. If I could find/make a script, then ROM Toolbox Pro would allow me to schedule and run the script nightly. Anyone have a script to compare 2 folders and only copy new and modified files from source to destination?

Sent from my Meanie ICS LTEvo
 

debarron

Senior Member
Mar 1, 2008
429
155
Here's a script I wrote to backup the DCIM folder from /sdcard to /sdcard2. If you want to copy the entire /sdcard, then you can change the DCIM after find to "." (w/o quotes) and change the destination (what's after -pdm) to just /sdcard2. This will copy anything that doesn't exist or is newer than the destination. The last two lines you can delete (du commands) as they just give the directory size of those two folders.


#!/system/bin/sh
( cd /sdcard ; find DCIM -depth -print | cpio -pdm /sdcard2/DCIM/.backup )
du -sk /sdcard/DCIM
du -sk /sdcard2/DCIM/.backup/DCIM

Sent from my EVO using Tapatalk 2
 
  • Like
Reactions: long_tall_texan

long_tall_texan

Senior Member
Feb 24, 2011
258
68
DFW, TX
Is there a way to also delete any files in destination that no longer exist in source folder? To keep folders truly synced/mirrored.

Sent from my Meanie ICS LTEvo
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Here's a script I wrote to backup the DCIM folder from /sdcard to /sdcard2. If you want to copy the entire /sdcard, then you can change the DCIM after find to "." (w/o quotes) and change the destination (what's after -pdm) to just /sdcard2. This will copy anything that doesn't exist or is newer than the destination. The last two lines you can delete (du commands) as they just give the directory size of those two folders.


    #!/system/bin/sh
    ( cd /sdcard ; find DCIM -depth -print | cpio -pdm /sdcard2/DCIM/.backup )
    du -sk /sdcard/DCIM
    du -sk /sdcard2/DCIM/.backup/DCIM

    Sent from my EVO using Tapatalk 2