Giter Site home page Giter Site logo

ssh-backup's Introduction

ssh-backup

An ssh subsystem for backups

This is a simple solution for centralised backups, with the help of OpenSSH and standard UNIX tools, designed to be installed on the hosts being backed-up. The single requirement is that the hosts run OpenSSH, which is used for certificate-based authentication and connection encryption. The subsystem itself is a simple shellscript, configurable via files in /etc/ETS-backup/, currently using tar(1) for backup collection, but easily modifiable for dump(8) or any other tool you prefer.

A sample installer script is provided for OpenBSD systems. Please generate your ssh keys that will be used for backups and adapt the script before running. This installer creates a separate user etsbackup with sudo(8) privileges and installs an ssh public key in ~etsbackup/.ssh/authorized_keys. The subsystem is installed in /usr/local/sbin/backup-subsystem.sh and the following is appended to /etc/ssh/sshd_config to configure sshd to always force the subsystem on user etsbackup:

Subsystem backup /usr/local/sbin/backup-subsystem.sh
Match user backup 
   ForceCommand /usr/local/sbin/backup-subsystem.sh
   AllowTcpForwarding no

After installing the subsystem on your hosts, simply create a user etsbackup on your central backup server, copy the private ssh keyfile to ~etsbackup/.ssh/id_rsa, and configure the server to receive backups on-demand using jobs like the following:

#!/bin/ksh
# daily backup script
#set -x
BKDIR=/mnt/backups/Network
DATE=$(date "+%Y/%m/%d")
HOSTS=/etc/ETS-backup/hosts.daily.list

if [ -s "${HOSTS}" ]
  then
  HOSTCNT=$(grep -c '[^[:space:]]' < "${HOSTS}")
  if [ $HOSTCNT -ne 0 ]
    then
    mkdir -p "$BKDIR/$DATE"
    for _host in $(<${HOSTS});do
      echo "Backup $BKDIR/$DATE/${_host}"
      sudo -u etsbackup ssh -T ${_host} > "$BKDIR/$DATE/${_host}.tgz"
    done
  fi
fi

Add hostnames or IP addresses of hosts to /etc/ETS-backup/hosts.daily.list and configure this to run daily via cron(8) to obtain backups from those hosts.

ssh-backup's People

Contributors

gadamo avatar proditis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.