Backing up iPhones over SFTP

If you've got a good amount of storage available and want to backup your iPhones easily over SFTP, you can do that pretty easily!

Previously, I was running NextCloud for my wife and I to backup our phones, but we found the chunky overhead of NextCloud for uploads unbearable (HTTP overlay, app, etc.) and it would take longer than regular "scp" commands would. That's a problem... and when we have a problem, we find solutions!

The most direct way for us was to get the FTPManager iOS application (also works on iPad) and have the files upload via this. There are many apps available to do this SFTP upload, but, most of them we tried were very not the most "user friendly" when it comes to the wife acceptance factor.

FTPManager stood out because of it's simple user interface, and that when uploading files (let's say 1000 pictures), it was the fastest app to upload with – while I can't speak to what the actual connection process is under the hood, it feels like a native "scp" client like you'd expect on your computer/server.

FTPManager Preview

The Setup

In order to make the changes, it started with the server. On my server, I created both my wife and I users for logging in and mounted a few folders so we can share files. Once this was done, I setup BackBlaze B2 with Restic to backup files every day at midnight on crontab.

From a directory perspective, here's how this looked:

/home/{wife,i}/{Pictures,Documents,Notes,iPad_Files,iPhone_Files} # personal folders (we're in a "shared" group for shared files)
/home/shared/ # shared folder (group: shared, chown: nobody:shared recursive)
/home/{wife,i}/shared (symlink to /home/shared)

Now, when we connect, our home file tree looks like:

/home/user/
 Pictures
 Documents
 Notes
 iPad_Files
 iPhone_Files
 shared

Keeping back-up to date

In order to back this data up one more level (because why not!), I setup restic for it. Restic will encrypt a copy of the data, and upload it to BackBlaze B2 on a crontab. Here's what my configuration looks like:

b2_env file:

export B2_ACCOUNT_ID=""
export B2_ACCOUNT_KEY=""
export RESTIC_REPOSITORY="b2:bucket_name"
export RESTIC_PASSWORD_FILE="/home/outofband/backup_config/restic_password.txt"

backup_script.sh file:

#!/bin/bash
set -e
cd /home/outofband/backup_config/
#### IMPORT ENV ####
. b2_env
#### DO THE BACKUP ####
cd /home/
restic backup .

Once this is in, my crontab runs this at midnight nightly, and we now have a fully encrypted, off-site backup on top of the iPhone/iPad offsite backup. Booyah!