How to backup to phone? Android as a destination?

i’ve got a lot of free GB on my phone i want to use for backups.

one idea is use duplicati to bckup locally, then sync that local backup folder to my phone using a different software like syncthing. but i don’t want to duplicate the data locally, i don’t have room.

my other idea is to run a webdav / ftp server on my phone? then target that? but idk what webdav even is. and that sounds insecure + battery hungry.

what’s the most simple way to do this?

i just downloaded FTP Server (Free) from F-Droid. duplicati instantly connected to it np. seems good!

1 Like

Very interesting… never thought I’d see someone back up their PC to their phone!

it actually crashed about half way through. and it always crashes. so this isn’t working for me.
i tried ftp, sftp, webdav, and using a bunch of different apps. it all fails before completing, at different points.(and i’m only backing up like 40gb)

i tried simply plugging in my phone via usb and backing up to it as a normal drive, but apparently that’s impossible in 2022 because you can’t mount Android to a drive letter anymore. the path is like: This PC\ONEPLUS A5000\Internal shared storage\ and Duplicati doesn’t like it

:frowning:

Important update: Termux seems to have an issue with Android 11+ writing to sd card. At least on my phone, the phone suggests the sd card has a problem but there’s no problem outside of Termux. However, Termux writes fine on Android 8 to it. Just something to know. Internal on Android 11+ seemed to be fine. 100GB of backups on Android 8 to sd card and all is good. Same as computer to computer SSH. End.

Old but the only one I found via search so adding another way. The same way I do from computer to computer. SSH.

Still testing but working great for a 400MB test backup on Android 12 non-rooted phone.

But, you can use ssh server on Android via Termux. Happens to be that it needs to be done from an F-Droid provided package as well as its the only way to get the start on boot for the updated Termux app unless one builds both from source which I believe should also work.

(They are not the download f-droid buttons in the links but are just below that)

Install Termux and Termux boot

Browse to Termux Android settings for the app and enable permission for storage

Open Termux

Roughly:

$ pkg install openssh
$ passwd
$ sshd -p 1234

Also for path, use a file explorer on the Android device and create a folder to backup to.

And in Duplicati you can ssh into it using sftp(ssh) with ip of Android device, port 1234, username u0_a274 and the password you supplied to passwd. Put the full path into Duplicati. You can then test connection and it should work assuming you have no firewall or other blockage if you have your networking all crazy.

For Termux boot, open Termux, you will create the script at $HOME/.termux/boot/start-sshd and you can use sshd -p 1234 or whatever (see the instructions in Termux boot app to know what to put into the start-sshd file). Start Termux boot and then ssh server will start even after the device is rebooted.

I’ve disabled battery optimizations for the apps as well.

Speeds are quite fast on my phone with 400MB not taking long at all. Also have to test battery usage further but so far its looking great.

24 hour test succeeded. Continued backups. No problems seen. Will be moving onto roughly backing up 100GB+ via two backups next asap.

Unfortunately anyway here - even with open source - requires a level of trust as it opens up the storage to the old way where apps could take data at will. While many of us devs are not that way, many devs are. These apps use old targets that Google allows to circumvent newer safety changes. FYI. You might be able to block the device from the internet as good enough safety via the router if its a device you won’t use the internet with.

By the way, an alternative:

You could use Syncthing to sync your Duplicati backup to the Android device. Syncthing is way too slow to do without a pre-contrainer backup such as Duplicati. You want to heavily minimize the amount of files Syncthing sends because of how badly slow it is which is still an understatement. I didn’t want to add yet another application on my computer for backups so decided not to go this way.


But, this or other sync applications are another way to go. However, also if Duplicati (in this instance) messed up the backup and you sync those backups then two separate backup choices would be broken at the same time which is bad bad bad. Something to think about.

New:

I just finished renovating an FTP server app for Android 11+ and including the storage security. Used constant backups via Duplicati of two computers to it to with each their own folder on one device while working on the app.

A little bit of info for Duplicati use here for comparison:

Tests done using:
Wifi ac 5ghz
256GB sd card on Android device
Android 12 with scoped storage security in place

Restoration times:
Using Local DB: 19 minutes for 22GB
Using DB at remote: 2 hours 13 minutes for 81GB

Backup MB/sec:
30-40MB
eg about 1.8-2.4GB per minute for backup sending of files.

Battery usage:
2 backups every 2 hours of computer on time (totaling about 100GB source) past 14 hours was 5.3%
In comparison, AOD was 3.3%.

So, for instance, its compatible with eg Android 6… Android 11, 12, should be with 13, etc

I’m not making an apk available so you’d have to build the app from source using GitHub - Xavron/swiftp at Scoped_storage or maybe wait to see if the app’s developer adds it to the official git and then adds it as an update to the Play Store version of that app. Its also free to build from source.

To put far too simply: its built in Android Studio so you’d install Android Studio, in the linked git project just download the zip of it and unzip it, open the project in Android Studio, attach the device to install it to via USB, and run it which will build it (assuming it goes well lol) and install the apk. That device would need sideloading enabled as well as USB debugging in Android’s developer settings at the very least.

Android Studio loves changing things and I might keep it relatively updated. But if you - who’s reading this and wanting to do it - run into a problem, please do not to ask me for help :slight_smile:

I will add, the only possible issue I’m seeing building in Android Studio at the moment is simply fixed by going into project structure, clicking on the notice link that JDK location was moved, and then setting Gradle JDK to version 11.

But, compared to the above app, Termux, the most important thing is that - using my source code changes - it now has scoped storage so that apps can’t access files not specifically allowed by the user. That’s including being fully worked on and with Android 11+. Termux currently has issues with all of that.

If you don’t understand what scoped security is and why its totally nice to have then this might help: What is Scoped Storage in Android? | Android Central

It doesn’t have encrypted SSL support. Its not something all that necessary when used at home only. That’s my use so I may or may not work on that in the future. It should have it but I’m done with the app for now.

Also, the app needs unrestricted battery use or many Android OS versions manufacturers put out there will kill it at any time. Without that, it just can’t stay working in the background. So, if there’s a connection failure then this is probably going to be the issue.

The current linked project also sends the app’s ftp password to the Android’s logcat btw. This is currently how the app creator has it. The logcat is rather public should you upload a crash log for Android or an app or something then it would be in there. I should link one with that dropped instead of one compatible with the app creator’s project. But its not a major issue at home on a local network so I will do it when I do it. You should be using unique passwords today anyway. No password should be the same.

Oh, and this linked one only auto starts on boot when using a 3rd party app (whatever it was called) that I will never use. I should also link one with a workaround but the super quick way I put together currently doesn’t auto start on all devices - the Android launcher just happens to do it on the one device I use.

Should, I change the linked project for these things then I will edit this post to reflect it.