Jump to content

Encrypted Backups from Your Seedbox with Pikkumies

From Pulsed Media Wiki

One sentence to Pikkumies backs up the files in your Pulsed Media seedbox that you cannot download again into an encrypted borg repository on a Storage Box. In the test run shown below it saved a Documents folder (3 files, 300 KB), listed the archive and checked that all three files were in it: 1 minute 59 seconds and about 21,500 AI credits.

Recorded on Pulsed Media test accounts: one Linux account stands in for your seedbox (shown as you@seedbox) and a second test account on the same Pulsed Media server plays the Storage Box (shown as boxuser@storagebox). Both clips come from one run of these steps. The key login to the box was set up off screen, and long waits are shortened.

What this route protects

The repository is created in borg's repokey mode: the data is encrypted with AES-CTR-256 and authenticated with HMAC-SHA256, and the key is stored in the repository, locked by your passphrase (borg init documentation). The Storage Box holds encrypted data, and with a strong passphrase the backup cannot be read without it.

Borg runs inside your seedbox account here, and Pikkumies keeps the passphrase in a file in that account (file mode 600) so that later backups need no typing. That file sits on a Pulsed Media server, within Pulsed Media's reach. So the backup is encrypted at rest on the Storage Box, and the passphrase is not kept away from Pulsed Media. A backup that only you can open is made from your own machine: the own-machine route covers it, and also what the AI credit service sees of a conversation with Pikkumies.

Why a seedbox needs a backup

Pulsed Media's general terms say the provider does not back up customer service data unless a service's details say otherwise, does not guarantee data retention, and asks account holders to back up their own data. An M-series seedbox runs RAID 5 and survives one failed drive, a V-series seedbox runs RAID 0 and does not, and on either RAID is not a backup.

Back up what you cannot fetch again: scripts, configuration, notes and documents. Downloads that a tracker or a mirror can supply again are the cheap loss. To have your torrent clients' settings and the rest of your configuration saved every night with no repository to set up, see Daily Encrypted Seedbox Backups with Pikkumies.

Before you start

  • Pikkumies installed in your seedbox account, with pikkumies doctor showing a key and a model (Pikkumies on PMSS has the three-step install).
  • A Storage Box, its server name and username. BorgBackup and Restic come pre-installed on the box. On the Debian 12 test accounts borg was version 1.2.4 on both sides.
  • AI credits for the request in Step 3.

Step 1: Key login from the seedbox to the box

Later backups run without anyone at the keyboard, so the login to the box has to work without a password prompt. In your seedbox shell, create a key and give it to the box once. Replace USERNAME and SERVERNAME with your own:

ssh-keygen -t ed25519
ssh-copy-id USERNAME@SERVERNAME.pulsedmedia.com

The same two commands are explained in Zero-Knowledge Backups with Pikkumies, and SSH covers keys in more detail.

Step 2: Create the repository and log in

This step stays with you because it needs the passphrase. Set the repository address once, create the repository, then log Pikkumies in to it:

export REPO=ssh://USERNAME@SERVERNAME.pulsedmedia.com/./borg-documents
borg init --encryption=repokey $REPO
php ~/pikkumies/tools/backup/borg/borg.php login --repo $REPO --human
The repository is created on the box and Pikkumies is logged in to it. The passphrase is typed three times and never shows on screen; the login ends with verified: yes.

borg asks for the passphrase twice, then asks whether to display it for verification; Enter answers no. Its closing text says the repository needs both the key and the passphrase to open, and that the key should be backed up separately. borg key export --paper $REPO prints the key for that. A repokey key also lives in the repository's config file, so an export guards against that file being damaged (borg key documentation). Write the passphrase down somewhere safe.

The /./ in the address makes the path relative to your home directory on the box. From then on Pikkumies hands the stored passphrase to borg through that file, never as text on a command line. The login refuses to run anywhere but a terminal.

Step 3: Ask for a backup

Then ask in plain words:

pikkumies "Back up my Documents folder to my borg repository now, then list the archives. Keep it short."
One request in the seedbox account: Pikkumies backs up Documents, lists the archives and opens the new one to check that its three files are in it. The archive name starts with the seedbox's server name, shown here as seedbox.

The answer comes with a receipt. Pikkumies is experimental and can be wrong, so read it against borg's own output:

  • the archive, named after the server and the UTC time of the backup, and how many files it holds (3 files, 300 KB);
  • the archive list from pikkumies borg list;
  • a check with borg show --files that each of the three files is in the archive.

The request used 21,540 credits, with 15 tool calls. A larger folder takes longer, and the number of steps the agent takes changes the cost from run to run. Pulsed Media AI Credits lists what each plan earns.

The same with restic

Restic is pre-installed on the box too, and its commands follow the same three steps. Pikkumies' restic steps are recorded and explained on Zero-Knowledge Backups with Pikkumies; this page's recording uses borg. Restic's SFTP path has no leading slash:

export REPO=sftp:USERNAME@SERVERNAME.pulsedmedia.com:restic-documents
restic -r $REPO init
php ~/pikkumies/tools/backup/restic/restic.php login --repo $REPO --human
pikkumies "Back up my Documents folder to my restic repository now, then check that the backup can be read back. Keep it short."

The seedbox account of the test run had restic 0.14.0.

Getting a file back

Pikkumies' borg instructions restore only into a new or empty folder inside your home, and a file is moved back with mv -n. The rules for restores and for removing old archives are the ones described in Zero-Knowledge Backups with Pikkumies. A restore is not part of the recording above.

Troubleshooting

  • Pikkumies says no repository is set up for this tool: Step 2 was not done in this account. Run the login line there.
  • The login refuses to run: it reads the passphrase from a terminal only, so run it in your own shell.
  • borg asks for a password or fails with Permission denied (publickey): the key login of Step 1 is missing.
  • disk quota exceeded: borg keeps a cache in ~/.cache/borg that counts against your quota, and on a full account it is often the cause. borg delete --cache-only $REPO removes it, and borg rebuilds it from the repository.
  • A borg check on a large repository: Pikkumies' borg instructions warn that on a box with 500 MB of memory a large repository can run out of memory during a check. Pikkumies checks only when you ask it to.

At Pulsed Media

Storage Boxes come with BorgBackup and Restic pre-installed, the M1000 Storage and M10G Storage 2.0 plans run RAID 5, and V10G Storage runs RAID 0. One copy on one box is still one copy, so keep a second one elsewhere (Zero-Knowledge Backups with Pikkumies says the same). See the Storage Box plans.

See also