Setup Borg Backup Server on

Setup Borg Backup Server on

There is a great coupon for borg and attic users. Which reduces the price to $0.03/GB/Month but without the same level of support the give normally.

To run a command on we need to use ssh -t as we are not given an interactive session. We can put the commands we want to run at the end of the ssh command.
Run ssh -t borg-server pwd so we can find what full path looks like.
It should look something like /data1/home/1234 remember this.

Next we want a new folder for the borg repo, I’m going to call it borg-repo
ssh -t borg-server "mkdir borg-repo; chmod 700 borg-repo"

The next command creates the repository and should be run on your machine not the server.
borg init -–encryption=repokey borg-server:borg-repo

Now for the optional part:
Create a file temp.authorized_keys on your computer with the contents
We’ll need that path you remembered from above. eg. /data1/home/1234

command="cd /data1/home/1234/borg-repo; /usr/local/bin/borg1 serve --restrict-to-path /data1/home/1234/borg-repo",no-port-forwarding,no-X11-forwarding,no-pty,no-agent-forwarding,no-user-rc ssh-rsa AAAAAAAAYOURKEYAAAAA== steven@yourcomputer.example

N.B. borg1 uses the lastest version of borg, just using borg uses a very old version.

Changing ssh-rsa AAAAAAAAYOURKEYAAAAA== steven@yourcomputer.example to your ssh public key.

Add any other keys you want to this file and then transfer using scp temp.authorized_keys borg-repo:.ssh/authorized_keys fix up permissions with ssh -t borg-server "chmod 700 .ssh; chmod 600 ssh/authorized_keys".

Now when you login using the private key it’ll be limited to the directory we just setup.

From the docs:
Due to the cd command we use, the server automatically changes the current working directory. Then client doesn’t need to have knowledge of the absolute or relative remote repository path and can directly access the repositories at <user>@<host>:<repo>.


I couldn’t make total sense what the above me and however I tried this command and it worked fine:
borg init --encryption=repokey borg-server:borg-repo/ to create your new repo.
Do it from your client

You can use commands like borg create to add archives to the repo:
borg create -v --stats -p --compression=none borg-server:borg-repo/::-date +%Y-%m-%d/path/to/directory

5 thoughts on “Setup Borg Backup Server on

    1. Thank you for this.

      In case isn’t obvious what the above means:

      $ ssh -t “borg –version”
      borg 0.29.0
      Connection to closed.
      $ ssh -t “borg1 –version”
      borg1 1.1.0

  1. also – it appears that you can only setup a repo on the home root; that is, can’t set it up under ‘borg-root’

    tested this on regular account, (pays the full rate not the borg/attic discounted rate)

  2. mistake on the two above posts.
    the remote path should be:
    `–remote-path /usr/local/bin/borg1/borg1`

    and it can be put into any directory – not just the root of home

    1. @jon , thanks for commenting! You are correct I only learnt about borg1 after I posted.

      My setup is slightly different where I use `/usr/local/bin/borg1 serve`in the authorized_keys file instead.

      Strange, I just checked and /usr/local/bin/borg1 appears to be a directory but using it works. *shurg* I’ll try find out which path is best to use.

      `–remote-path` is the best way to do it if one is not using authorized_keys file.

Leave a Reply

Your email address will not be published. Required fields are marked *