#!/bin/bash # # $Id: remote-ssh-gpg-backup,v 1.1 2003/10/25 12:23:13 suter Exp $ # Copyright (C) 2003 Mark Suter # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ## Our "die" function (think perl) function die () { echo "$@" 1>&2 ; exit 1 ; } ## Set our PATH and test for needed binaries export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin hash test md5sum find cpio gpg ssh || die $0: required binaries not present ## Get the passphrase and check it against the md5sum we have stored echo -n "Passphrase: " read -s passphrase test "$(echo $passphrase | md5sum)" == "dd02c7c2232759874e1c205587017bed -" || die $0: passphrase does not match md5sum echo ok. ## The Heart of the Script - please customise to your needs find /path/to/backup -print0 | \ cpio --null --format=crc --create | \ gpg --no-use-agent --passphrase-fd 3 --batch --quiet --symmetric 3< <(echo "$passphrase") | \ ssh remote.example.org cat \> backup.cpio