archiving photos from phone to PC

This has been mentioned before, but I am looking into preserving pictures on the PC, for which there is no space on the phone. Ideally, photos and videos deleted on the phone, would still be there on the PC. It seems Gaute had a great solution mentioned here. Unfortunately that topic is closed, and I am too new to be allowed to send private messages.

Does anyone (maybe Gaute her/himself) have the mentioned script? Or a better script?

On the Syncthing side of things, if I understand correctly the trick is to make the folder on the phone Send-Only, and the folder on the PC not Receive-Only but a normal folder.

Is that correct? Are there better ideas?

Thanks!

Not really, using “Send Only” on the phone will only prevent changes from the PC from being synced to the phone, but changes from the phone will still sync to the PC. “Changes” in Syncthing terms mean both additions, modifications, and deletions.

Honestly, I would advise against using scripts like that if you cannot write one yourself (and especially since this kind of a script is rather simple). What I would do is to simply enable File Versioning for the folder on the PC (with no time limit), and then once you delete pictures on the phone, you can go to the versions folder and restore the files into a different, local directory on the PC.

The reason for not recommending using scripts is that if you don’t know exactly what you’re doing, you can easily wreck havoc on the system with them.

1 Like

I haven’t done it myself yet but it seems to me that you just need to enable file versioning. Trash Can mode should be fine.

On your PC, create an archive folder on the same drive as the synced photos folder. Then enable versioning on the PC and set the archive folder as the Versions Path. Set the “cleanout after” and “cleanup interval” to zero.

Now a normal two way sync should work just fine. Any files you delete from the phone will be moved to the archive folder on the PC. Just make sure you sync before deleting on the phone. Any files you manually move on the PC will be deleted from the phone.

Another note of caution - if your phone creates an image file with the same name as one already archived, the archived copy could get overwritten. If you think that’s a possibility then look at other versioning modes or regularly move stuff from the archive to a permanent folder.

Thanks for your answers! I would obviously be much happier with some automated solution, but I understand your suggestions. I am not sure what a versioning folder/path is - is that a Windows-specific thing? My laptop has Linux Mint.

I will look into writing a script myself. If Gaute reads this, I am still interested in yours, since you claim it has some clever actions and that might inspire me for covering corner cases that i have not thought about

In general I would like to remark that this specific question (photos on phone wanting to keep, but phone does not have space for them all obviously) is a very common one. There are proprietary solutions like Ente, Google Photos, and Apple Photos/iCloud, obviously. I still hope to find something more private and less expensive

Please check https://docs.syncthing.net/users/versioning. If you were to use your own script for versioning, then you would want to utilise https://docs.syncthing.net/users/versioning#external-file-versioning for it.

Here’s another solution (adapted from a subset of mine) if the goal is to use Syncthing as the file transfer tool…

First, create something like the following set of directories on each device:

Phone:

/storage/
└── emulated
    └── 0
        ├── DCIM
        └── DCIM-Archive

On most modern Android devices, /storage/emulated/0/DCIM is usually already the default destination for phones and videos from the camera app, so probably only need to add a DCIM-Archive directory.

Laptop:

~/Photos
├── DCIM
├── DCIM-Archive
└── LTA

Syncthing…

  1. In Syncthing, configure sync folders for DCIM and DCIM-Archive, pairing each with their respective counterparts on the phone and laptop.
  2. Set the DCIM-Archive Syncthing folder to “Send & Receive” on both devices.
  3. Optionally, set the DCIM Syncthing folder to “Send Only” on the phone and “Receive Only” on the laptop for extra protection.

Long-Term Archiving…

On your Linux Mint laptop, use a simple cron job to regularly move files from ~/Photos/DCIM-Archive/ to ~/Photos/LTA/:

# Min	H	DoM	M	DoW	Command
0		*	*	*	*	cd ~/Photos ; for FILE in $(find DCIM-Archive -type f -not -name ".*") ; do LTA="LTA/$(date +%Y/%m/%d --reference $FILE)" ; mkdir --parents $LTA ; mv $FILE ${LTA}/ ; done &> /tmp/LTA.log

Basic details about the crontab shown above:

  • The scheduled task runs at the top of every hour (e.g. 00:00, 01:00, 02:00,…) whenever your laptop is powered up.
  • To steer clear of Syncthing’s .stfolder, .stignore and temporary files, the find command is told to ignore any filenames that start with a dot (.) – there’s an edge case where Syncthing uses a tilde (~) that’s not covered here.
  • To lessen the chances of filename collisions, or ending up with tens of thousands of files in a single directory, each file is moved into a subdirectory based on its file timestamp – you could get really fancy with exiv2, mediainfo and/or some other metadata utility, but that’s way beyond the scope of this post. :smirk:
  • In the event of a filename collision, the move will fail (because by default, the mv command won’t clobber an existing file). The file will remain in DCIM-Archive until the conflict is resolved either by renaming the file on the phone, or the matching filename on the laptop.

Camera image/video file management workflow…

Now whenever you want to free up storage on your phone, instead of deleting selected images and videos, move them from DCIM to DCIM-Archive.

Syncthing will then mirror the moves on your laptop. And as your laptop’s cron job moves files from ~/Photos/DCIM-Archive/ to ~/Photos/LTA/, it effectively “deletes” them from your phone without elaborate shell scripts or manipulating Syncthing’s versioned files repository.

Notes…

  • Backups. Backups. Backups.
    • If the data is important, the “long-term archive” requires redundancy.
  • Obviously, customize the directory paths as needed for your local requirements.
  • Because files are being moved, rather than deleted, there’s minimal risk of accidental loss (of course, the risk is higher if you decide to move files to a different storage volume).
  • The last portion (&> /tmp/LTA.log) is optional. It simply captures any console output to the file /tmp/LTA.log for review:
    • Regularly manually review the log.
    • Automated task to scan the log for error messages and post an alert – e.g. desktop pop-up, email, SMS, or any number of messaging channels.
3 Likes

That is really a great and inspiring suggestion. Very detailed explanations which is super helpful for me.

I especially love the idea of having two photos folders, which makes it possible to delete a photo from the phone in two ways: deleting as in throw away, and deleting-but-keep-a-copy-on-the-laptop. I must say at first sight I am a bit apprehensive about the idea of giving every photo its own folder, I’ll ponder a bit on how name collisions can be mitigated differently.

By the way, in your opening paragraph you mention ‘if the goal is to use Syncthing as the file transfer tool’. That is (at least for me) not a goal in itself. If there is another way for achieving the same result, I’d happily do that!

By the

Although syncing /storage/emulated/0/DCIM isn’t technically required in the archival scheme, it helps provide some redundancy for photos/videos that haven’t been archived yet.

No worries, the date command in the example crontab above only goes as far as day of the month. Try the following on your laptop:

date +%Y/%m/%d --reference /path/to/some/image.jpg

So any photos/videos that share the same month+day+year file timestamp are grouped together like so:

~/Photos/
└── LTA
    └── 2024
        └── 08
            └── 10
                ├── IMG_20240810_190019069.jpg
                └── VID_20240810_112625138.mp4

That way, if you decide to use Syncthing to mirror ~/Photos to another device, you won’t run into the issue of slow sync due to resource thrashing when processing a folder with tens of thousands of files.

I’ve seen quite a few posts from users who want to replicate a Google Photos experience using Syncthing even though those are completely different types of applications and workflows.

Just a few of the available photo/video management options:

Alternatively, could do a homebrew solution that combines a mesh network (e.g. Tailscale, ZeroTier) + rsync/FTP/SFTP/WebDAV client + suitable server software.

Self-hosted VPN:

Overlay VPN networking:

Android file transfer apps:

2 Likes

this is amazing!! thanks so much. Your patient, welcoming and very clear explanations are really lovely to read.

I reply a bit too early, because there is so much research to be done before I can react appropriately. But I wanted to point out that the ZeroTier link seems to have a typo: it links to zerotier.co, but I guess it should be zerotier.com? (also useful for any others reading along now or later)

You’re welcome. :grinning:

Thanks for catching that typo! (I corrected the link).

Hi,

I have a solution that I use for a similar purpose that works very well. No script writing and not complicated.

It is an application that can do a copy rather than sync.

You can set up an automatic schedule for it to copy new and modified items on your phone to your computer without deleting anything on your computer. If you delete items on your phone following the copy they will not be deleted on your computer.

Its an app called Roundsync. It’s available on GitHub not in the Google Play app store. And even though sync is in the name it can also do a plain copy.

Once you have it installed there are three main menu sections one called remotes one called tasks and one called triggers.

  1. Configure remote to your windows or linux computer.
  2. Create a task that copies from local to remote new and changed files.
  3. Set up a trigger to make it happen automatically on a schedule if you wish. I run it manually myself because I don’t know when I’m going to have both computer and phone turned on and be in the same place.

Roundsync is Rclone for Android.

This way there is no scripting. There is no directory structure to create or anything else to do that’s not in a simple graphical user interface.

You can also add file encryption if you wish. Everybody was an Android phone has a Gmail account and you can store files in an encrypted state this way.

You’re I think interested in local storage rather than cloud storage so encryption would not be required.

Sometimes you want to synchronize and other times like this one you simply want to copy files from one place to another without deleting or synchronizing anything.

Let me know if you have any questions. I’ve been a user and supporter for years. I provide complimentary tech support on their Forum too.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.