seedvault-app / seedvault

A backup application for the Android Open Source Project.
1.3k stars 75 forks source link

Support SFTP as backup option #354

Open FieryBinary opened 2 years ago

FieryBinary commented 2 years ago

SSHFS is a FUSE-based tool that mounts directories using an SSH connection. It is a simple FUSE wrapper around SCP and SFTP and does not require any special setup yet is incredibly versatile.

Using SSHFS, it will be very simple and easy to back up, since it only requires the server's SSH key. Any computer whose key is imported can be used. Currently, flash drives are clunky to carry around, and Nextcloud requires a good deal of setup before it can be used.

It needs integration and making a GUI wrapper for it, since to my knowledge Android supports FUSE, and since it's Linux, you can reuse the original SSHFS implementation. Also, it needs a SAF frontend so Seedvault can easily use it.

yoxcu commented 2 years ago

Would also love to see this feature!

Nairou commented 2 years ago

I came here to request this. Whether it be SSHFS, or just a simple SSH connection to dump a locally-generated backup. I don't use NextCloud, so SSH would be a generic option to get the backup off of the device.

AgnivaChaudhuri commented 2 years ago

This would be incredibly useful and I'm glad you brought this up.

Reading through the Android storage provider documentation, a generic SSHFS app should work well. A standalone app will maximize versatility for any use case (outside of Seedvault too), and Seedvault can just pass file requests to this app. I will open a new repository for this.

AgnivaChaudhuri commented 2 years ago

Actually this might be a little harder than anticipated. Looking up "Android SSHFS client", I found this app. /dev/fuse requires root on Android, so that's not possible on a non-rooted device.

SSHFS is just a FUSE wrapper around SFTP like you said, so maybe we could make a new wrapper that directly uses the storage framework, no FUSE required. This would turn it from "SSHFS client" to "SFTP client" with the same functionality. There might be apps that already do this whose code we can reuse.

Nairou commented 2 years ago

I believe SSHFS is difficult because it attempts to make the SSH connection appear as a filesystem, which is a very low-level thing to be messing with.

By contrast, there are many SSH client apps available. We don't need a full filesystem emulation, we just need a SSH network connection and a path to write the backup to on the remote machine.

Even if this was as a secondary step, after the backup was written to the local filesystem, the contents were then sent over SSH, it would still achieve the goal of getting a backup off of the device.

chirayudesai commented 2 years ago

Even if this was as a secondary step, after the backup was written to the local filesystem, the contents were then sent over SSH, it would still achieve the goal of getting a backup off of the device.

That won't scale - SeedVault supports file backups now, which can backup the entire internal storage, so you may not have space to cache the entire thing, only a small part.

AgnivaChaudhuri commented 2 years ago

Even if this was as a secondary step, after the backup was written to the local filesystem, the contents were then sent over SSH, it would still achieve the goal of getting a backup off of the device.

You'd still need to see all the past backups. Otherwise you'd backup the whole phone each time which wastes lots of space. But...we definitely don't need a filesystem wrapper, just a way to present a remote directory for writing and reading.

Let's search for open-source SFTP clients that let other apps see the files.

jarkad commented 1 year ago

Let's search for open-source SFTP clients that let other apps see the files.

Material Files provides SFTP mounts via SAF.

chirayudesai commented 1 year ago

Let's search for open-source SFTP clients that let other apps see the files.

Material Files provides SFTP mounts via SAF.

Just to confirm, that means you setup SFTP in the Material Files app, and then it shows up in the phone's normal Files app?

jarkad commented 11 months ago

Just to confirm, that means you setup SFTP in the Material Files app, and then it shows up in the phone's normal Files app?

Material Files acts as a Document provider[https://spot.pcc.edu/~mgoodman/developer.android.com/guide/topics/providers/document-provider.html]. Mounted directories show up in file picker when an app sends ACTION_OPEN_DOCUMENT intent, but not when you open Files app from home screen.

l-o-u-i-s-g commented 8 months ago

why not just sync the files with scp? 1 : connect to server check /download last backup meta-data file if available 2: find what files have changed in the current meta-data file vs meta-data file from ssh server 3: upload through scp files that have changed 4: upload last meta-data file

there's an ssh flutter plugin that allows to do scp to an ssh server. I'm using this in one of my app to backup the database of my app. https://pub.dev/packages/dartssh2