Remix.run Logo
Rygian 10 hours ago

My usecase for Termux: most pictures get backed up properly into the home NAS, but the sync process sometimes skips a few [1] (which is exasperating, but here we are still not migrated to Immich).

So I have a python script in the NAS that calculates the MD5 checksum of every photo and video, and generates a shell script that, when executed on the phone, will calculate the MD5 on the local device, and delete if it is equal to the NAS.

The generated shell script gets sent to the phone, then I execute it from within a Termux window, pointing at the DCIM folder.

I can free up tens of GB of memories with reliability in the face of a misbehaving sync algorithm.

[1] https://help.nextcloud.com/t/auto-upload-is-skipping-random-...

jcynix 9 hours ago | parent | next [-]

With Termux I have rsync at hand, which can compute checksums, delete files after the transfer, etc. That's why I do my complete backup with Termux. And I sort the images on the phone into dated subfolders before syncing them.

And having tools like exiftool, ffmpeg, and ImageMagick among others available in Termux is wonderful.

troyvit 6 hours ago | parent [-]

Yeah same in fact that's how I discovered Termux. I had an rsync.net account and thought that since rsync and ssh are so ubiquitous it should be simple to set up back-ups from my android phone. Boy was I wrong. The android apps that support rsync were all janky or suspiciously closed. Termux + rsync + Termux API's job scheduler does the trick. I think it's a bit of a drain on my phone battery but I won't complain given I own my photo back-ups from top to bottom (though I rent from rsync.net)

dizhn 9 hours ago | parent | prev | next [-]

That nextcloud issue is quite weird and people seem to have had better luck with the sync app downloaded from places other than the Play store. I personally would lose any confidence in the app and use a completely separate thing to do the syncing if that happened to me. I actually did use the nextcloud client on pc a while ago and it was kind of fickle in other ways too anyway so I stopped using it.

ktm5j 9 hours ago | parent [-]

I really like SeaFile for this kind of thing. It follows the "do one thing and do it well" philosophy. It's just file sync with some basic document editing features (markdown, .doc I think). Super fast and dependable, highly recommend.

https://www.seafile.com/en/home/

ksynwa 6 hours ago | parent | prev | next [-]

Are you sure all this is really necessary? I just use round sync to copy over the camera and whatsapp media folders over ssh/sftp to my SBC. Then once every several months I delete the files from these foldes which exceed a given mtime (using find in termux).

Rygian 5 hours ago | parent [-]

I take it as a personal preference to never delete a copy of a file I care about, until I have taken positive proof that it is copied safely where it belongs.

I have deep trust issues with commands that work on more than one file at a time.

overfeed 6 hours ago | parent | prev | next [-]

> I execute it from within a Termux window...

If you install Termux widgets, you can directly start the script from your Android launcher's Home screen.

Rygian 5 hours ago | parent [-]

Since this process happens just a couple times per year, I find it reassuring to edit the file on the phone, check its contents, run it first in dry-run (the default), grep the output to my leasure, and only then run it in anger.

overfeed 3 hours ago | parent [-]

The widget would be overkill. My tasks were more frequent - several times weekly. The scripts were a hacked-up first step towards cron automation, and occasionally needed to be re-run. Everything is now in a neat, cron-triggered Home Assistant automation with events instead of questionable 'sleep' lines.

thekoma 9 hours ago | parent | prev [-]

How come you don’t just send the md5s to delete rather than the shell script?

Rygian 4 hours ago | parent | next [-]

That would definitely work too.

What I like about my process is that there is only one source script (the python one) to keep around.

vasco 9 hours ago | parent | prev [-]

I guess it's a more flexible design that allows to change the criteria for deletions in the future. You still need to calculate md5s on the phone either way.