Giter Site home page Giter Site logo

borg-snapshot's Introduction

borg-snapshot

borg is a modern backup solution. Its features include e.g.:

  • encryption
  • block based deduplication
  • server with append only mode
  • ...

borg is a command line tool configured with parameters and environment variables. Setting it up to regularly create backups, usually means writing some scripts. This is where borg-snapshot steps in to help.

borg-snapshots lets you setup a client server backup solution creating backups every hour. It will backup almost your entire root file system. However some big cache files are excluded (see borg-snapshot-create.sh). It uses the one file system option, so every other filesystem will be excluded.

I use it to backup my servers and desktops.

Installation

Server

Borg uses ssh to securely connect to the server. borg-snapshot uses a ssh key and the authorized_keys file to restrict the clients permissions on the server. In fact the clients backup key is only allowed to do backups. So it is essential to disable password logins on the backup server via ssh. E.g. by:

echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
systemctl restart ssh.service

It is necessary to install borg on the server and on the client. As I run debian stable, I did it with:

apt install borgbackup -t stretch-backports

Clients

No further tasks need to be done on the server. After installing borg on the client, too. One needs to clone borg-snapshot's repository only on the client:

git clone [email protected]:BenSartor/borg-snapshot.git
cd borg-snapshot

Create a config file containing a server and a password for the backups.

cat <<EOF > borg-snapshot-settings
#!/bin/sh

BORG_PASSPHRASE="n0t5ecure"
SERVER=backup.example.org
EOF

As we want to backup the root file system, we need to start the backup as root. A root login to the backup is only needed for initialisation. The following script will create a ssh key (/root/.ssh/id_borg-snapshot_ed25519). After that it will create a user on the backup server, assign the ssh key to it and restrict it to borg backup.

sudo ./borg-snapshot-init.sh

Now it is time to create your first backup. This might take some time.

sudo ./borg-snapshot-create.sh

Using cron to regularly invoke the backup script is pretty easy but using systemd timers is much more flexible and includes an awesome logging solution. The following script will create a systemd timer.

sudo ./borg-snapshot-create-systemd-timer.sh

The next backup will start in 30 seconds. You may watch it with:

journalctl -f -u borg-snapshot.service

borg-snapshot.sh is a simple wrapper around borg, setting up everything to use your remote backup repository. You may use it with the parameters of the borg executable. E.g. the following command lists your backups.

sudo ./borg-snapshot.sh list

In order to restore files from your backup, you need to mount it.

sudo ./borg-snapshot-mount.sh

You may umount it like this:

borg umount /media/backup

Deinstallation

If for any reason you want to remove your backup again, you may use the following script. It will remove everything created, including your backups, the backup user on the server, the systemd timer and borg-snapshot's ssh key.

sudo ./borg-snapshot-delete.sh

borg-snapshot's People

Contributors

bensartor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

igaw

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.