GithubHelp home page GithubHelp logo

sftbackup's Introduction

sftbackup

Simple wrapper for borg backup and snapper

Remote backup setup

You can store the backup over SSH on a remote server.

This even works for multiple clients to one server as borg can jail clients by ssh forced commands.

Client setup

Backup targets:

  • Remote server via SSH (you have a borg remote url)
  • Local storage (secondary harddrive, a nfs/samba mount, ...)

Remote backup client preparation

If you do your backup remotely via SSH, you need a SSH key first.

  • Generate ssh-key for user root
    • Of course you may reuse an existing ssh key, but root has to be configured to use it.
HOME=/root sudo ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519_backup
  • Provide your ssh public key in /root/.ssh/id_ed25519_backup.pub to the server operator
  • Configure SSH to use the right user and ssh key in /root/.ssh/config:
# example config if your borg backup remote url is "[email protected]:reponame"
Host borgbackup.somewhere.net
    User borg
    IdentityFile ~/.ssh/id_ed25519_backup

Client configuration

  • Configure sftbackup in /etc/sftbackup.cfg
  • Set password = ... to encrypt the backup
    • To generate a password, you can use pwgen 30 1
    • Note down the password somewhere (to be able to restore the backup!)
  • Use repo = ... to specify where to store the backup
    • Remote backup via SSH: repo = [email protected]:reponame
    • Local storage, e.g. external HDD: repo = /mnt/backupdrive
  • Adjust other things like paths, excludepaths, ...

Repo creation

  • Create the repo: sudo sftbackup init
  • This will initialize the borg repo in repokey mode.

Test backup

  • Test the creation of the first backup by running sudo sftbackup backup

Automated runs

This is only suitable for devices that are permanently running (e.g. servers)

  • Install the sftbackup.timer and sftbackup.service systemd units
  • Enable and start the sftbackup.timer

Enjoy your backups!

Server setup

Repo storage:

  • Create a borg user on your host: sudo useradd -m borg
  • Create the storage directory: sudo mkdir /home/borg/repos.
  • Create the authorized_keys file in /home/borg/.ssh/authorized_keys
    • Ensure the .ssh and authorized_keys file belong to user borg

Client access:

  • Create a directory /home/borg/repos/clientname (owned by user borg)
  • Grant access in authorized_keys:
command="cd /home/borg/repos/clientname; borg serve --restrict-to-repository /home/borg/repos/clientname/reponame --storage-quota 1.5T",restrict ssh-ed25519 client's_ssh_public_key_... root@clientname
  • Add --append-only to disallow this client to remove data in its repos (very handy so a server can't delete its own backup when hacked).
  • See man borg-serve for further information on how to restrict client access

Restore

Contributing

As you might have guessed, you can report issues and submit patches through pull requests easily.

License

GNU GPLv3 or later; see copying.md and legal/GPLv3.

sftbackup's People

Contributors

thejj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

thejj enzingerm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.